我有一个模板字符串:模板字符串存储为常数
function getTemplateString() {
let videoId = 'qwerty'
return `https://player.vimeo.com/video/${videoId}?api=1`
}
我想存储在const
而不是这个模板字符串:
const VIMEO_EMBED_URL = `https://player.vimeo.com/video/${videoId}?api=1`
function getTemplateString() {
let videoId = 'qwerty'
// how can I do this next line?
return VIMEO_EMBED_URL.something({videoId: videoId})
}
我可以做常量字符串插值?
我猜不是:[“模板字符串中的所有字符串替换是JavaScript表达式”](https://developers.google.com/web/updates/2015/01/ES6-Template-Strings?hl=zh-CN ) – sennett