[英]Vue 2 Prop value not rendering in the template
I have this code where I am trying to render a value from prop in the template but getting a 我在尝试从模板中的prop渲染值的地方得到了这段代码,但得到了
Uncaught ReferenceError: channel is not defined
未捕获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>
and here is the markup: 这是标记:
<div id="items_app">
<itemstable
:channel="selectedChannel"
></itemstable>
</div>
I have tried changing the name of the prop thinking 'channel' might be a reserve word, but the same thing happens. 我曾尝试更改道具的名称,认为“频道”可能是保留字,但同样的事情也会发生。
将javascript插值${}
更改为vue表达式{{}}
template: `<div>{{channel}}</div>`,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.