(1) +号方式
var htmlSTring = "<div>"+
"this is a string"+
"</div>";
(2) \方式
var htmlSTring="<div>\
This is a string.\
</div>"
(3) es6方式
var htmlSTring = `<div>
This is a string.
</div>`;
es6传变量方式
var b = "hello world"
var htmlSTring = `<div>
This is a string: ${b}.
</div>`;
对比总结:
es6方式简洁不容易出错,打印结果有所差别, \ 方式会保留一些空格,es6的字符串模板 ` (在esc键下方)方式会保留换行,还支持传变量