我一直收到如下报错信息:.../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。