在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/網(wǎng)絡安全  HTML/ 請問pug模板如何遍歷傳遞的數(shù)組數(shù)據(jù)?

請問pug模板如何遍歷傳遞的數(shù)組數(shù)據(jù)?

根據(jù)文檔,傳遞變量到模板中渲染可以通過以下方式:

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

回答
編輯回答
只愛你
let htmlArr = this._assign.map((item) => {
    return template(item)
})

this.innerHTML = htmlArr.join('')
2018年1月6日 12:50