TS 字符串新特性
2017-10-24 本文已影响0人
__凌
No 1:声明多行字符串: ` 这里面支持换行 `
No 2:字符串模板 : `I am ${变量名}` , `I am ${方法调用}`
eg:
var str =`
<div>
<p>${userName}</p>
<p>${getInfo()}</p>
</div>
No 3:自动拆分字符串:当将字符串模板应用到某一函数中时,将根据某种规则将模板进行拆分,拆分成函数相应个数的参数并调用

Array[3]
0:"hello my name is "
1:", I am "
2:""