const person = {
name: 'Wes',
job: 'Web Developer',
city: 'Hamilton',
bio: 'Wes is a really cool guy that loves to teach web development!'
}
const emailData = '<div class="person"><h2>${person.name}</h2><p class="location">${person.city}</p><p class="bio">${person.bio}</p></div>'
我有一个对象,我想用emailData绑定该对象数据。
我的期望是:
<div class="person"><h2>Wes</h2><p class="location">Hamilton</p><p class="bio">Wes is a really cool guy that loves to teach web development!</p></div>
1条答案
按热度按时间jexiocij1#
假设你想在React中得到答案,你描述的这个模式很容易转换成一个组件:
然后,您可以将其称为:
或者,如果你已经有了
person
对象,你可以使用spread操作符: