在客户端创建 html 元素并为元素设置多个属性的最快安全方法是什么

问题描述

嗨,我是 node js devoleper,我想知道在客户端创建 html 元素并在其上设置多个属性快速且安全的方法是什么 目前我正在使用

//looping through data got from the server 

data = [{id:1,topic:'topic1',content:'content'}]

data.forEach(d=>{     document.getElementById('container').innerHTML += ` <div id="${d.id}" class="class1 class2">
<p class="topic class3" >${d.topic}</p>
<p class="content class3" >${d.content}</p>
</div> `
})
<body>
  <div id='container' > 
  </div>
</body>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)