Heim > Fragen und Antworten > Hauptteil
代码如下
<p id="box6">
<my-component2 :showInfor="hello"></my-component2>
<my-component2 :showInfor="hi"></my-component2>
</p>
<script type="text/javascript">
Vue.component('my-component2',{
props: ['showInfor'],
template: "<p><h4>{{showInfor}}</h4></p>",
computed: {
showInforRes: function(){
return this.showInfor+" world!"
}
}
})
var com2 = new Vue({
el: '#box6'
})
</script>
报错如下
迷茫2017-04-11 13:21:36
<p id="box6">
<my-component2 show-infor="hello"></my-component2>
<my-component2 show-infor="hi"></my-component2>
</p>
<script type="text/javascript">
Vue.component('my-component2',{
props: ['showInfor'],
template: "<p><h4>{{showInfor}}</h4></p>",
computed: {
showInforRes: function(){
return this.showInfor+" world!"
}
}
})
var com2 = new Vue({
el: '#box6'
})
</script>
//说明:属性前去掉冒号,冒号表面是动态属性。同时改成-链接形式,不要驼峰形式,这是推荐标准写法。