记录一个小技巧基于ES5的多行字符串拼接,增加html模板的可读性var htmlString = “<div>"+ “This is a string."+ “</div>";ES6中使用的模板字符串可以让我们的多行html模板更简洁var htmlString =
<div> This is a string. </div>`;然而它们在 IE 下并没有被支持,如果你需要在不经过 Babel 或类似的工具编译的情况下支持 IE,可以使用使用折行转义字符来增加代码的可读性。var htmlString = “<div>\ This is a string.\ </div>";Reference:Multiline String Variables in JavaScript