请问pug模板如何遍历传递的数组数据?

根据文档,传递变量到模板中渲染可以通过以下方式:

var template = require("pug!./file.pug");
// => returns file.pug content as template function

// or, if you've bound .pug to pug-loader
var template = require("./file.pug");

var locals = { /* ... */ };

var html = template(locals);
// => the rendered HTML

传递字符串类型过模板中可以正常渲染出来,请问如何传递OBject类型到pug中遍历输出内容?

clipboard.png

阅读 5k
1 个回答
let htmlArr = this._assign.map((item) => {
    return template(item)
})

this.innerHTML = htmlArr.join('')
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题