使用“\n\t”将多行字符串拼接起来

以前js拼接字符串有好多 \n \t

不使用ES6

使用“\n\t”将多行字符串拼接起来:

var roadPoem = 'Then took the other, as just as fair,\n\t'
+ 'And having perhaps the better claim\n\t'
+ 'Because it was grassy and wanted wear,\n\t'
+ 'Though as for that the passing there\n\t'
+ 'Had worn them really about the same,\n\t'

使用ES6

将多行字符串放在反引号``之间就好了:

var roadPoem = `Then took the other, as just as fair,
And having perhaps the better claim
Because it was grassy and wanted wear,
Though as for that the passing there
Had worn them really about the same,`
ES6确实很好啊
posted @ 2017-08-21 10:57  Martin_lee  阅读(715)  评论(0编辑  收藏  举报