【问题标题】:Vue Warn: Property or method is not defined on the instance but referenced during renderVue警告:属性或方法未在实例上定义,但在渲染期间引用
【发布时间】:2021-11-27 12:51:27
【问题描述】:

我在组件标签中定义了一个型号名称,如下所示:

 <b-table-column v-if="" field="columnName" v-slot="itemProps">
              <SelectableAttribute
                  :attr-name="props2.row.fieldClass"
                  :attr-id="itemProps.row.id"
                  :model-id="props.row.id"
                  :model-name="NewParticipant"
              >

但是我收到此错误:

[Vue warn]: Property or method "NewParticipant" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. 

我不太确定我应该如何定义模型名称,我假设在我的道具中,但在哪里?我在下面附上了代码。

    export default {
  props: {
    participants:
        {
          type: Array,
          default: null
        },
  },

  components: {
    SelectableAttribute
  },

【问题讨论】:

    标签: vue.js vuejs2


    【解决方案1】:

    正如您的错误告诉您的那样,NewParticipant 未定义。您需要将其作为data() 中的属性添加到您的组件中,如下所示:

    data() {
        return {
          NewParticipant: [] // Array for example
        }
      }
    

    否则,如果你希望你的 prop participantsmodel-name,你需要将它更改为 :model-name="participants"

    【讨论】:

      猜你喜欢
      • 2019-02-20
      • 2020-06-22
      • 2019-08-12
      • 2018-09-24
      • 2017-11-14
      • 2020-04-01
      • 2021-08-13
      相关资源
      最近更新 更多