给定一个数组section1,它包含2个对象title和content,帮助我将这2个对象的数据输出到动态创建的<div class=“card”中
{type: 'main', section1: [
{title: 'title_one', content: 'cont_1'},
{title: 'title_two', content: 'cont_2'}
]
}
function main (content) {
const html = content.section1.map((item, index) => `<div class="card">
<h1>${content.title[index]}</h1>
</div>`)
return `
<main>
<section>${html.join('')}</section>
</main>`
}
1条答案
按热度按时间p4tfgftt1#
取代
与