Node.js 使用意外令牌返回错误{

Node.js 使用意外令牌返回错误{,node.js,express,pug,Node.js,Express,Pug,我一直在第18-19行发现一个错误,在本例中,dayClick行表示: 意外标记{ 在函数本地 在assertExpression C:\websites\timeoffcalendar\node\u modules\jade\lib\lexer.js:30:33 在Object.Lexer.C:\websites\timeoffcalendar\node\u modules\jade\lib\Lexer.js:509:11 在Object.Lexer.next C:\websites\time

我一直在第18-19行发现一个错误,在本例中,dayClick行表示: 意外标记{ 在函数本地 在assertExpression C:\websites\timeoffcalendar\node\u modules\jade\lib\lexer.js:30:33 在Object.Lexer.C:\websites\timeoffcalendar\node\u modules\jade\lib\Lexer.js:509:11 在Object.Lexer.next C:\websites\timeoffcalendar\node\u modules\jade\lib\Lexer.js:914:15 在Object.Lexer.lookahead C:\websites\timeoffcalendar\node\u modules\jade\lib\Lexer.js:113:46 在Parser.lookahead C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:102:23 在Parser.peek C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:79:17 在Parser.block C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:704:30 在Parser.tag C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:817:24 在Parser.parseTag C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:738:17 在Parser.parsexpr C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:211:21 在Parser.block C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:708:25 在Parser.tag C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:817:24 在Parser.parseTag C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:738:17 在Parser.parsexpr C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:211:21 在Parser.block C:\websites\timeoffcalendar\node\u modules\jade\lib\Parser.js:708:25

block content
  script.
    $(document).ready(function() {
      // page is now ready, initialize the calendar...
      $('#calendar').fullCalendar({
        eventSources: [
          {url: '/getevents'}, 
          {url: "/javascripts/Holidays.json"},
        ],
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: true,
        dayClick: function(date, jsEvent, view) {
            $('#calendar').fullCalendar('changeView', 'agendaDay');
            $('#calendar').fullCalendar('gotoDate', date);
        },
        eventClick: function(event, jsEvent, view) {
            $('#editModalTitle').html(event.title);
            if(Cookies.get("fullAdmin") != "undefined"){
              var sdate = event.start.format().split("T")[0];
              var stime = event.start.format().split("T")[1];
              var edate = event.end.format().split("T")[0];
              var etime = event.end.format().split("T")[1];
              $("#startday").val(sdate);
              $("#starttime").val(stime);
              $("#endday").val(edate);
              $("#endtime").val(etime);
            } else {
              $('#startDate').html("Start date: "+event.start.format());
              $('#endDate').html(" End Date: "+event.end.format());
            }
            $('#dayoffid').val(event.id);
            $('#fullCalModal').modal();
            return false;
        }
      });
      if(Cookies.get("date") != "undefined"){
        $('#calendar').fullCalendar('gotoDate', Cookies.get("date"));
        Cookies.remove("date");
      }
      $('#allday').change(function() {
        if(document.getElementById('allday').checked == true) {
          $('#starttime').val("09:00:00");
          $('#endtime').val("17:00:00");
        } 
        });
      $('#startday').change(function () {
        $('#endday').val($('#startday').val());
        });
      $('#saveevent').click(function(){
        $.ajax({
          type: "POST",
          url: "/calendar/"+$('#startday').val()+"/"+$('#starttime').val()+"/"+$('#endday').val()+"/"+$('#endtime').val()+"/"+$('#typeoptions').val()+"/"+$('#useroptions').val()      
          }).success(function(msg){
            window.location.reload();
          });
        });
      $('#updateEvent').click(function(){
        $.ajax({
          type: "PUT",
          url: "/calendar/"+$('#startday').val()+"/"+$('#starttime').val()+"/"+$('#endday').val()+"/"+$('#endtime').val()+"/"+$('#typeoptions').val()+"/"+$('#useroptions').val()      
          }).success(function(msg){
            window.location.reload();
          });
        });
      $('#addEvent').click(function(){
          $('#createModalTitle').html("Book a day off!");
          $('#inputCalModal').modal();
          return false;
        });
      $('#removeEvent').click(function() {
        if(confirm("Are you sure you want to delete the event?")) {
          $.ajax({
          type: "DELETE",
            url: "/calendar/"+$('#dayoffid').val()             
            }).success(function(msg){
              window.location.reload();
          });
        }
      });
    }); 

我认为你的jade模板没有问题,我用这段代码在上面试用过

doctype html
html(lang="en")
  head
   title= pageTitle
  body
   block content
   script.
    $(document).ready(function() {
    // page is now ready, initialize the calendar...
    //And the rest of your script

    });

而且它生成了没有错误的有效html

为什么不将整个脚本写在一个单独的文件中,并将其包含在scriptsrc=中,然后检查缩进