app.use('/broadcast',function (req,res) {
var name,detail,input;
detail=['ID','管理员','玩家名','操作状态','操作时间','内容'];
name='操作日志';
input='<label>玩家名</label> <input type="text"> <label>操作</label> <input type="text"> <label>状态</label> <input type="text"> <label>开始时间</label> <input class="datainp wicon" id="time1" type="text" placeholder="开始日期" readonly=""> <label>结束时间</label> <input class="datainp wicon" id="time2" type="text" placeholder="结束日期" readonly=""> <input type="button" value="查询" class="btn btn-primary"/>'
var form={"name":name,"detail":detail};
res.render('inner',
{title:'broadcast',
_input:input,
_form:fillTable(form)})
})
function fillTable(form){
var fstr;
for(var i=0;i<form.detail.length;i++){
fstr+="<th>"+form.detail[i]+"</th>"
}
var content='<div class="box border blue"> <div class="box-title">' +form.name
+'</div> <div class="box-body"><table class="table table-hover"> <thead> <tr>'+
fstr+' </tr> </thead> <tbody></tbody> </table> </div> </div>'
// console.log(content);
return content;
}
这边多了个undefined
jade模板
变量类型为字符串的时候,应该赋上初始值
var a = ''
。