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