在javascript中使用for html模板

Using for template of html in javascript

本文关键字:for html 模板 javascript      更新时间:2023-09-26

为什么我使用下面的代码得到了TOKEN意外非法的错误?

var html = '<div id="wrap">'
    <img style="width:100%;display:block">'
  <div>''
  console.log(html);

我使用'进行转义,它应该可以正常工作。。

问题如下:

<div>''

您正在转义结束语。

试试这个

var html = '<div id="thermal-close-sales-wrap">'
    <img style="width:100%;display:block">'
  <div>'
  console.log(html);