每个错误:无法读取未定义的属性“长度”

时间:2016-10-07 14:55:01

标签: node.js express pug

我不明白为什么会抛出以下错误。我的所有脚本都在每个循环中加载,但我很难看到未定义的变量。

错误

TypeError:
C:\...\views\layout.pug:13
  11|                 include navbarBottom
  12|
> 13|                 each script in scripts
  14|                          script(type='text/javascript', src=script)
  15|
  16|

Cannot read property 'length' of undefined

register.js

router.get('/', function(req, res, next) {
  res.render(
    'register', {
      user: User.build(), 
      title: "Register",
      scripts: [
        '/javascripts/plugins/jquery.min.js',
        '/javascripts/plugins/bootstrap.min.js',
        '/javascripts/plugins/bootstrap-multiselect.js',
        '/javascripts/plugins/jquery-intlTelInput.js',
        '/javascripts/plugins/jquery-intlTelInputUtils.js',
        '/javascripts/register.js',
      ]
    }
  );
});

register.pug

extends layout

block content

    #register-page.main.container...

layout.pug

doctype html
html
  head
    title #{title}
    link(rel='stylesheet', href='/stylesheets/style.css')
  body
    include navbarTop

    block content

    include navbarBottom

    each script in scripts
      script(type='text/javascript', src=script)

0 个答案:

没有答案