根据文档,传递变量到模板中渲染可以通过以下方式:var template = require("pug!./file.pug");// => returns file.pug content as template function// or, if you've bound .pug to pug-loadervar template = require("./file.pug");var locals = { /* ... */ };var html = template(locals);// => the rendered HTML传递字符串类型过模板中可以正常渲染出来,请问如何传递OBject类型到pug中遍历输出内容?
1 回答
饮歌长啸
TA贡献1951条经验 获得超3个赞
let htmlArr = this._assign.map((item) => {
return template(item)
})
this.innerHTML = htmlArr.join('')
添加回答
举报
0/150
提交
取消