我有一個模板字符串:模板字符串存儲爲常數
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