api返回的接口数据是这样的"<div>测试数据</div>"

js拼接html时会过滤掉<div></div>

所以需要对<div></div> 进行转译

如下函数

1     function html2Escape(sHtml) {
2         return sHtml.replace(/[<>&"]/g, function (c) { return { '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' }[c]; });
3     }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2021-11-14
  • 2021-12-23
猜你喜欢
  • 2021-05-21
  • 2021-09-14
  • 2021-09-29
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案