[英]Vue 2 Prop value not rendering in the template
我在嘗試從模板中的prop渲染值的地方得到了這段代碼,但得到了
未捕獲ReferenceError:未定義通道
<script>
Vue.component('itemstable', {
template: `<div>${channel}</div>`, // this is where the error occurs.
props: ['channel'],
data() {
return {
}
}
})
new Vue({
el: '#items_app',
data: {
selectedChannel: 'pos',
channels: JSON.parse(`["pos","kiosk"]`)
}
})
</script>
這是標記:
<div id="items_app">
<itemstable
:channel="selectedChannel"
></itemstable>
</div>
我曾嘗試更改道具的名稱,認為“頻道”可能是保留字,但同樣的事情也會發生。
將javascript插值${}
更改為vue表達式{{}}
template: `<div>{{channel}}</div>`,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.