【问题标题】:Problems with Jade, Unexpected character #Jade 的问题,意外的字符#
【发布时间】:2014-01-13 09:29:39
【问题描述】:

我不断收到:.../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 '='

这是我的玉文件:

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。

【问题讨论】:

    标签: javascript node.js syntax pug


    【解决方案1】:

    github readme.md:

    Jade 版本 0.31.0 已弃用隐式文本,仅支持脚本和样式。要解决此问题,您只需 添加一个 .脚本或样式标记后的字符

    还有玉docs:

    通常您可能希望标签中包含大块文本。一个很好的例子是内联脚本或样式。为此,只需添加一个 .标签之后(前面没有空格)

    script.而不是script

    【讨论】:

    • 谢谢先生!我会一直试图解决这个问题很长时间。在我看来,改变这一点的奇怪决定。它也反对语义版本控制。他们在颠覆中引入了向后不兼容的更改,而不是主要更改。无论如何,谢谢!
    猜你喜欢
    • 2012-06-19
    • 1970-01-01
    • 2015-02-13
    • 2022-12-18
    • 2013-07-05
    • 2016-01-12
    • 2012-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多