【问题标题】:Vue.js props undefinedVue.js 道具未定义
【发布时间】:2020-06-09 12:58:08
【问题描述】:

执行此代码时,输​​出“未定义”。


子组件

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"。
我该怎么办?

【问题讨论】:

    标签: vue.js vue-component vue-props


    【解决方案1】:

    你的文字道具有错字) 波普斯:[ 'idx' ]

    换成道具

    【讨论】:

      猜你喜欢
      • 2017-07-08
      • 1970-01-01
      • 2019-04-05
      • 1970-01-01
      • 2023-04-08
      • 2016-11-08
      • 2018-04-10
      • 2018-04-18
      相关资源
      最近更新 更多