Vue.js 道具未定义
Vue.js props undefined
执行这段代码时,输出"undefined"。
子组件
export default {
porps: [
'idx'
],
mounted () {
console.log(this.idx)
},
} //BambooPage.vue
父组件
<template>
<div class="bamboo">
<bamboo-page v-bind:idx="index" v-if="show"></bamboo-page>
</div>
</template>
<script>
import BambooPage from '@/components/Bamboo/Page/BambooPage.vue'
export default {
name: 'bamboo',
data: () => {
return {
show: false,
index: 0
}
},
components: {
BambooPage
},
mounted () {
this.index = 5
this.show = true
},
}
</script>
在 Vue Devtools 上,子组件中有 $attars "idx: 5"。
我该怎么办?
你的单词道具有错字)
波普斯:[
'idx'
]
道具变更
执行这段代码时,输出"undefined"。
子组件
export default {
porps: [
'idx'
],
mounted () {
console.log(this.idx)
},
} //BambooPage.vue
父组件
<template>
<div class="bamboo">
<bamboo-page v-bind:idx="index" v-if="show"></bamboo-page>
</div>
</template>
<script>
import BambooPage from '@/components/Bamboo/Page/BambooPage.vue'
export default {
name: 'bamboo',
data: () => {
return {
show: false,
index: 0
}
},
components: {
BambooPage
},
mounted () {
this.index = 5
this.show = true
},
}
</script>
在 Vue Devtools 上,子组件中有 $attars "idx: 5"。
我该怎么办?
你的单词道具有错字) 波普斯:[ 'idx' ]
道具变更