门外汉请教js怎么给ejs模块传数组变量或者对象?
门外汉请教js怎么给ejs模块传数组变量或者对象? app.get(’/query’, function (req, res) {
res.render('query', {
title: '查询',
bb1: i,
bb2: i++,
bb3: i,
bb4: i,
bb5: i,
bb6: i,
bb7: i,
bb8: i,
bb9: i,
bb10:i,
user: req.session.user,
怎么把bb1~bb10,改为bb[10]之类,试过一些方法都没用?求指点
2 回复
var param = {
title: '查询',
user: req.session.user
};
for(var i = 1; i <= 10; i ++) {
param['bb' + i] = i;
}
res.render('query', param);
多谢