【发布时间】:2021-06-09 21:30:49
【问题描述】:
我有一些 html 转换为模板字符串,当我选中复选框时出现上述错误,我知道它与 ${currentRow} 有关,只是不知道为什么它会这样做
function RowChecked(row) {
...
}
const currentRow = ds.find(f => f.ItemID === itemId);
return `<input id='${currentRow.Area}_${currentRow.ItemKey}' type='checkbox' class='checkbox' onChange='RowChecked(${currentRow})' />`;
【问题讨论】:
-
onChange='RowChecked(${currentRow})'所以你想传入对象?? -
@epascarello,是的,对不起,我应该将其添加到我的问题中
-
将整个对象放入其中是一个非常糟糕的主意。那里可能有更好的解决方案,但如果不知道所有代码就很难说。
-
过去你必须使用
className而不仅仅是class,但这可能已经改变了 -
@Pointy 您可以在将 html 构建为字符串时使用类....
标签: javascript html jquery template-strings