Nodejs玉石问题
我的翡翠视图我给了数组'arr':
server.js
app('/', function (req, res) {
res.render('index', {
arr: [1,2,3]
});
});
我的索引视图我需要做这样的事情:
index.jade:
- if (arr && arr.length) {
for (var i=0; i<arr.length; i++)
div(class='div-'+arr[i])
- }
最终我想得到以下html代码:
<div class='div-1'>
<div class='div-2'>
<div class='div-3'>
但它确实有效。怎么了?
I my jade view I give the array 'arr':
server.js
app('/', function (req, res) {
res.render('index', {
arr: [1,2,3]
});
});
I my index view I need to make something like this:
index.jade:
- if (arr && arr.length) {
for (var i=0; i<arr.length; i++)
div(class='div-'+arr[i])
- }
Eventually I want to get the following html code:
<div class='div-1'>
<div class='div-2'>
<div class='div-3'>
But it does work. What's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自述文件(在 github 上) 包含语法下的一些示例。
这个例子应该做你想要的:
或者在你的情况下
The readme (on github) contains some examples under Syntax.
This example should do what you want:
or in your case