v-bind綁定的參數(shù)名不能用駝峰嗎?用了駝峰好像就不是<li>標(biāo)簽里的文本了,而是li標(biāo)簽里的一個(gè)屬性
<body>
<div id="root">
<ul>
<todo-item
v-for="it in lists"
v-bind:todoContent="it"
>
</todo-item>
</ul>
</div>
<script>
Vue.component('todo-item',{
props: ['todoContent'],
template: '<li>{{todoContent}}</li>'
})
new Vue({
el: "#root",
data: {
lists: ['123','123','423','1415']
},
methods: {
change: function() {
this.content = "hello change";
this.show = !this.show;
},
openli: function() {
this.subListOpen = !this.subListOpen;
?
}
}
})
</script>
</body>
2019-07-31
是的,不能用大寫(xiě),也不能用‘-’連接
2019-03-07
剛剛看了下官方文檔,明白了:因?yàn)閔tml是不區(qū)分大小寫(xiě)的,v-bind:綁定的其實(shí)是todocontent,然而在組件里是js語(yǔ)法區(qū)分大小寫(xiě),參數(shù)名是todoContent,所以接收不到參數(shù)
這樣就行了