简述:
实现列表循环输出(备忘)
代码:
jade
!!!5 html head title #{title} link(rel='stylesheet', href='/static/css/style.css') link(rel='stylesheet', href='/static/css/bootstrap.css') script(type='text/javascript', src='/static/js/jquery-1.8.3.js') script(type='text/javascript', src='/static/js/jquery-ui-1.9.2.custom.js') script(type='text/javascript', src='/static/js/bootstrap.js') script(type='text/javascript'). $(function(){ //console.info(list.length) }); body header h1 TESTLoop #{title} .container .main-content block content ul - each obj in list li= obj._id .sidebar block sidebar footer p Running on node with Express, Jade and Stylus
后台render页面的时候,将获取到的list值传入jade模板,用于展现
js 处理数据获取
exports.list = function(req, res){ deviceService.getDevices(null, function(result){ res.render('deviceList', { title: '数据列表', list: result, actionPath: "/device/list" }); }); };
输出: