vue语法 `${ }` (模版字符串)

时间:2020-12-04 21:30:09   收藏:0   阅读:112
const name = ‘小缘‘
const age = 14
console.info(`大家好,我叫${name},今年${age}岁了`)
// 等价于
console.info(‘大家好,我叫‘ + name + ‘,今年‘ + age + ‘岁了‘)
 
// 最大的优势是支持换行字符串
const url = ‘//baidu.com‘
const text = ‘百度一下,你就知道‘
const html = `
  <div class="container">
    <a href="${url}">${text}</a>
  </div>
`
console.log(html)
console.log(typeof html)

 

原文:https://www.cnblogs.com/xiejn/p/14087744.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!