1.JS拼接字符串太长希望换行保持html格式拼接
let elDynaLi = '\
<li class="first-li">\
<a>\
<img src="' + dynaLi[i].src + '" alt="">\
<span>' + dynaLi[i].date + '</span>\
<p>' + dynaLi[i].desc + '</p>\
</a>\
</li>\
'
2.模板字符串
2.1空格,缩进,换行
如果使用模板字符串表示多行字符串,则所有的空格、缩进和换行都会被保留在输出中。
3.replace替换
stringObject.replace(regexp/substr,replacement)
返回值
一个新的字符串,是用 replacement 替换了 regexp 的第一次匹配或所有匹配之后得到的。
4.字符串方法
6.模板字符串为键
this[`${option}Loading`]
7.字符串长度
<script>
var txt = "Hello World!";
document.write(txt.length);
</script>
9.包含某字符串
https://www.cnblogs.com/rxbook/p/11820720.html
https://blog.csdn.net/zhenyu5211314/article/details/52081202
10.字符串插入
e.split("").join("\n");
11.字符串截取
slice(),substr(),substring()
https://blog.csdn.net/lhjuejiang/article/details/82415472
if (item.professionName.length > 5) {
xAxisData.push(`${item.professionName.slice(0, 4)}...`)
}
else {
xAxisData.push(item.professionName)
}