小编Dra*_*tis的帖子

node.js中意外的保留字导入

我正在尝试运行node.js后端服务器.我unexpected reserved word在Node.js文件中导入时收到错误.

文件中的行core.module.js是:

'use strict';
import lodashMixins from './lodashMixins.js'
... other imports and configurations ...
Run Code Online (Sandbox Code Playgroud)

我启动简单的命令: node core.module.js

这并不罕见,但通常会发生在其他库中.我还没有看到Node.js的解决方案.我该怎么解决这个问题?我正在使用Windows Server.

编辑:我发现它是ES6,但我怎么能启动它?它看起来像应用程序的后端,但我不知道我应该使用什么命令来启动它而没有错误.

javascript importerror node.js ecmascript-6

53
推荐指数
2
解决办法
8万
查看次数

去杜松子酒框架CORS

我正在使用Go gin框架杜松子酒

func CORSMiddleware() gin.HandlerFunc {
    return func(c *gin.Context) {
        c.Writer.Header().Set("Content-Type", "application/json")
        c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
        c.Writer.Header().Set("Access-Control-Max-Age", "86400")
        c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
        c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Max")
        c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")

        if c.Request.Method == "OPTIONS" {
            c.AbortWithStatus(200)
        } else {
            c.Next()
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我有状态码:200 OK,但OPTIONS请求后没有任何反应.看起来我想念一些东西,但我无法理解我错在哪里.

有谁能够帮我?

frameworks go cors preflight go-gin

16
推荐指数
5
解决办法
1万
查看次数

Django:自动生成目录中的文件列表

我在我的网站上使用图片库应用程序.目前我将图像文件放在目录中,并手动为每个图像编写img html标签.是否可以让django自动在目录中创建文件列表,并将json输出发送到gallery应用程序,这样我就可以使用javascript <img>为每个图像文件生成元素.或者,每当请求gallery应用程序时,我是否可以直接使django为<img>目录中的每个文件自动生成元素.

python django image list

8
推荐指数
2
解决办法
1万
查看次数

在组件中加载初始数据时,如何在react-transition-group中暂停动画?

我有以下App组件:

            <Route render={( { location } ) => (
                <TransitionGroup component="div" className="content">
                    <CSSTransition key={location.key} classNames="slide" timeout={{
                        enter: 1000,
                        exit: 300
                    }} appear>
                        <Switch location={location}>
                            <Route exact path='/' component={Intro}/>
                            <Route path="/history" component={History}/>
                            <Route path="/rules" component={Rules}/>
                            <Route path="/faq" component={Faq}/>
                            <Route path="/feedback" component={Feedback}/>
                            <Route path="/partners" component={Partners}/>
                        </Switch>
                    </CSSTransition>
                </TransitionGroup>
            )}/>
Run Code Online (Sandbox Code Playgroud)

它工作正常,但每个动画立即执行.例如,如果我走的时候/rules/history,我得到了这两个组件全动画,但历史组件需要从服务器获取数据,因此应用在集装箱空箱的动画.

我怎么能在react-transition-group组件中暂停动画?我有Redux,所以我可以loading在我的应用程序的任何地方更改变量.另外,我不想在app start上预加载商店中的所有数据.

javascript reactjs react-router react-transition-group

8
推荐指数
1
解决办法
589
查看次数

如何在Thymeleaf中迭代X项?

我有模板,对于四个li元素,我应该有一个ul元素.我该怎么做?现在我有类似的东西:

<div th:each="excursion,iterStat : ${excursions}">
    <ul th:if="${iterStat.index}/4 == 0">
        <li>
            <a th:href="@{/excursion/{id}(id=${excursion.excursionId})}"><img src="/template/images/garden1.jpg" alt="Image" /></a>
            <h2 th:text="${excursion.title}"></h2>
            <p th:text="${#strings.abbreviate(excursion.description,128)}"></p>
        </li>
    </ul>
</div>
Run Code Online (Sandbox Code Playgroud)

我认为if条件将应用于elvery ul元素,但它隐藏了所有东西,包括li元素.

thymeleaf

7
推荐指数
1
解决办法
2万
查看次数

如何强制组合框渲染自动完成选项?

这是我的zul代码:

<combobox id="digitalPublisherCombobox" value="@load(ivm.inventory.digitalPublisherName)"
        onOK="@command('setDigitalPublisher', digitalPublisherBox = self)" 
        onSelect="@command('setDigitalPublisher', digitalPublisherBox = self)"
        onChanging="@command('setupQuicksearchByEvent', searchlayout = event, prefix = 'PUB', tags = 'PublisherName, PublisherNameTranslit')"
        mold="rounded" hflex="1" buttonVisible="false" autodrop="true">
    <comboitem self="@{each=entry}" value="@{entry.key}" label="@{entry.value}"/>
</combobox>
Run Code Online (Sandbox Code Playgroud)

这是QuickSearch实现:

@Command
public void setupQuicksearchByEvent(@BindingParam("searchlayout")Event event, @BindingParam("prefix") String prefix, @BindingParam("tags") String tags) throws WrongValueException, SearchException, IOException
{
    if(event instanceof InputEvent)
    {
        InputEvent inputEvent = (InputEvent) event;
        String inputText = inputEvent.getValue();

        List<String> searchFields = Arrays.asList(tags.split(","));
        ListModel model = new ListModelMap(ZKLogic.findDocsStartingWith(prefix, searchFields, "proxy", inputText), true);
        ListModel subModel = ListModels.toListSubModel(model, Autocompleter.MAP_VALUE_CONTAINS_COMPARATOR, …
Run Code Online (Sandbox Code Playgroud)

java zk

6
推荐指数
1
解决办法
2537
查看次数

如何在Spring中删除auth请求?

在此输入图像描述

这条消息说:Required authorization. To access on the server http://localhhost:8080 you should enter login and password. Server message: Spring.

我正在使用Hibernate 4,Spring 4和Gradle.另外,我正在使用Spring Boot.但即使我从教程中获得了平面代码,也会出现此消息.是什么引起了它以及如何摆脱它?怎么了?控制台中没有错误消息.

java spring hibernate spring-mvc

6
推荐指数
1
解决办法
7612
查看次数

带有特殊字符的 dompdf

我有以下代码:

\n\n
$pdf = \\App::make(\'dompdf\');\n$pdf->loadView(\'offers.pdf\',compact(\'email\',\'messages\'));\nreturn $pdf->stream();\n
Run Code Online (Sandbox Code Playgroud)\n\n

pdf.blade.php:

\n\n
<!doctype html>\n<html class="no-js" lang="sk">\n<head>\n    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n    <title></title>\n    <style type="text/css">\n        * {\n            font-family: "Arial";\n        }\n    </style>\n</head>\n<body>\nRozpo\xc4\x8det, Volite\xc4\xben\xc3\xa9 \xc4\x8dasti\n</body>\n</html>\n
Run Code Online (Sandbox Code Playgroud)\n\n

PDF 文档如下所示:

\n\n
Rozpo?et,Volite?n\xc3\xa9 ?asti\n
Run Code Online (Sandbox Code Playgroud)\n\n

但我需要显示文件中的特殊字符pdf.blade.php,你有什么解决方案吗?

\n

special-characters dompdf laravel-5

5
推荐指数
1
解决办法
3635
查看次数

如何在Django管理面板中获取当前记录的用户ID?

我有模型消息,它是表单管理器.要填写"user"和"groups"字段,我需要知道当前记录的用户ID,但我不知道如何在保存之前获取它.

class Message(models.Model):
    title = models.CharField(max_length = 100)
    text = models.TextField()
    date = models.DateTimeField(auto_now_add=True)
    user = models.ForeignKey(User, null = True, blank = True)
    main_category = models.ForeignKey(MainCategory)
    sub_category = models.ForeignKey(SubCategory)
    groups = models.ManyToManyField(Group)

class MessageAdminForm(forms.ModelForm):
   def __init__(self, *arg, **kwargs):
       super(MessageAdminForm, self).__init__(*arg, **kwargs)  
       self.initial['main_category'] = MainCategory.objects.get(title = 'News')
Run Code Online (Sandbox Code Playgroud)

django django-models django-admin

3
推荐指数
1
解决办法
4812
查看次数

python-social-auth - 我怎么能在 Django 中断开连接?

我正在使用a带有 href like 的标签,/disconnect/backend/然后它向我显示了一个空页面。我试过{% url %}模板标签,如:

{% url 'social:disconnect' 'twitter' %}
Run Code Online (Sandbox Code Playgroud)

它仍然创建与我在标签中使用的相同的 url。我怎么能断开帐户?或者也许还有一种方法可以只关联一个帐户?

python django python-social-auth

2
推荐指数
1
解决办法
1004
查看次数