//包含变量或表达式
const a = 10
const b = 20
const c = ‘html‘
const str = `my age is ${a + b} i love ${c}`
//包含逻辑运算的用法
function Price (strings,type){
let s1 = strings[0]
const retailPrice = 20
const wholeSalePrice = 16
let showTxt
if(type === ‘retail‘){
showTxt = ‘购买单价是:‘ + retailPrice
}else{
showTxt = ‘购买的批发价是:‘ + wholeSalePrice
}
return `${s1}${showTxt}`
}
let showTxt = Price`你此次的${retail}`
console.log(showTxt)
//换行写法
let s = `第一行
第二行`
console.log(s)
原文:https://www.cnblogs.com/qjb2404/p/12210236.html