执行此代码时,将输出“未定义”。
子组件
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"。
我能怎么做?