0
这是我的代码意外的标记错误的onclick
const products = productArray.map(product =>
`
<tr>
<td>${product.id}</td>
<td>${product.type}</td>
<td>${product.price}</td>
<td><button onclick="${() => console.log('hello world')}">Examine</button></td>
</tr>
`
);
return tableBody.innerHTML = products.join('');
我只是不明白为什么我得到这个意外的标记错误,它指向的HTML。我很确定这是一个非常愚蠢的,但我不能得到它在哪里。
OK所以没有办法,我可以添加此功能,例如: function clickHere(){console.log('hi')} –
您可以定义func '
我建议您使用客户端模板引擎来避免此类问题。例如mustachejs。
但是关于修复(试试这个):
来源
2017-06-04 22:05:13 num8er
在我用这个解决方案的目的,这是一个贝蒂因为其他更短:
来源
2017-06-04 23:45:52