Jade出现问题,出现意外字符#。

3

我一直收到如下报错信息:.../views/index.jade:20 18| alert(error) 19| }) > 20| server.on('warning',function(warning){ 21| alert(warning) 22| }) 23| var num = -1 Unexpected character # expected ' ', '\n', ',', '!' or '='

这是我的jade文件:

extends layout


block content
    #splash(style='z-index: 3120; position: absolute; left:0; top:0; width:100%; min-height:100%; background-color:#444;')
        img(src="/stylesheets/some.png", style='display:block; margin-left: auto; margin-right: auto; margin-top:10%;')
    div.row
        #welcome
        div.row
            #joined.small-6.columns
            #finished.small-6.columns
    script
        $(document).ready(function(){
        var server = io.connect()
        $.fn.exists = function(){return this.length>0}
        var userName = "none"
        server.on('error',function(error){
            alert(error)
        })
        server.on('warning',function(warning){
            alert(warning)
        })
        var num = -1
        server.on('welcome', function(data){
            userName = data.name
            num = data.num
            $("#splash").delay(2000)
                .queue(function(n){
                $(this).fadeOut(1000, function () {
                    $(this).remove()
                    $("#welcome").html("Welcome "+data.name)
                    $("#welcome").fadeIn(1000)
                    $("#welcome").delay(2000)
                        .queue(function(n){
                            $(this).fadeOut(1000, function () {
                                $(this).remove()
                            })
                            n()
                        })
                })
                n()
            })
        })
        server.on('joined', function(name){
            num += 1
            $("#joined").append("<p>"+name+" joined</p>")
            $("#joined p").last().delay(1000)
                .queue(function(n){
                    $(this).fadeOut(1000, function (){
                        $(this).remove()
                    })
                    n()
                })
        })
        server.on('finished', function(name){
            num -= 1
            $("#finished").append("<p>"+name+" logged out</p>")
            $("#finished p").last().delay(1000)
                .queue(function(n) {
                    $(this).fadeOut(1000, function () {
                        $(this).remove()
                    })
                    n()
                })
        })
    })

我错在哪里了?我想不出来。这个用早期版本时可以运行的。那个版本也允许编写普通的JavaScript。

1个回答

6

jade github readme.md:

Jade 0.31.0版本停用了对脚本和样式的隐式文本支持。要解决这个问题,您只需要在脚本或样式标签后面添加一个"."字符即可。

并且jade文档:

通常您可能希望在标签内有大块文本。一个很好的例子是使用行内脚本或样式。为了做到这一点,只需在标签后面添加一个 "."(没有前导空格)

script改为script.


1
谢谢您!如果没有您的帮助,我可能会一直卡在这里。我认为更改这个决定很奇怪,而且也违反了语义化版本控制。他们在子版本中引入了不兼容的更改,而不是主要的。无论如何,还是非常感谢您! - Automatico

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接