js拼接html中onclick方法传入对象方式

转成json对象传入(说明:需要将转后的双引号修改为单引号,否则会报错)

JSON.stringify(item).replace(/\"/g, "'")

正确使用如下:

<button οnclick="updateInfo('+JSON.stringify(item).replace(/\"/g, "'")+')">按钮</button>

猜你喜欢

转载自blog.csdn.net/weirdo_world/article/details/123707885