作为我的问题标题。 我无法显示var myArray的值。请帮我。我开始使用nodejs,ejs。
index.js:
res.render('index',{
nickName: 'My Nick',
fullName: 'My Name',
myArray: [
myClass = 'nodeJs',
mySchool = 'Home School'
]
});
index.ejs
<div>My Nick is: <%= nickName %></div>
<div>My Name is: <%= fullName %></div>
<div>My Class is: <%= myArray['myClass'] %></div> // can't print
<div>My School is: <%= myArray['mySchool'] %></div> // can't print
<div>My Array is: <% myArray.forEach(function(value){ %>
<%= value %>
<% }) %>
谢谢!
答案 0 :(得分:-1)
myArray: [
myClass = 'nodeJs',
mySchool = 'Home School'
]
应该是
myArray: [
myClass: 'nodeJs',
mySchool: 'Home School'
]
答案 1 :(得分:-1)
myArray: [
myClass = 'nodeJs',
mySchool = 'Home School'
]
这显然不是JS代码。大概应该是这样的:
myArray: {
myClass: 'nodeJs',
mySchool: 'HomeSchool'
}