美文网首页
利用ES6中的模板字符串轻松实现多行和字符串值的插入

利用ES6中的模板字符串轻松实现多行和字符串值的插入

作者: 小菜101 | 来源:发表于2017-07-19 16:35 被阅读0次

多行字符串

// Multiline strings
`In JavaScript template strings can run
 over multiple lines, but double and single
 quoted strings cannot.`
// 如打印或者输出,是多行的结构

字符串值的插入

// String interpolation
var name = 'Bob', time = 'today';
`Hello ${name}, how are you ${time}?`
// console:   "Hello Bob, how are you today?"

相关文章

网友评论

      本文标题:利用ES6中的模板字符串轻松实现多行和字符串值的插入

      本文链接:https://www.haomeiwen.com/subject/yoglkxtx.html