美文网首页
组件是默认值报错:Props with type Object/

组件是默认值报错:Props with type Object/

作者: 努力与幸运 | 来源:发表于2021-04-19 18:39 被阅读0次

产生问题的出处

@Prop({
    type: Object,
    default:  { picTypeNicNames: [], sriovTypeNicNames: [] };
    }
  })
  private usedNicNameList!: any;

解决办法 props传递数据的时候,默认值如果是数组或者对象,应该使用一个函数返回默认值

@Prop({
    type: Object,
    // Props with type Object/Array must use a factory function to return the default value.
    default: () => {
      return { picTypeNicNames: [], sriovTypeNicNames: [] };
    }
  })
  private usedNicNameList!: any;

相关文章

网友评论

      本文标题:组件是默认值报错:Props with type Object/

      本文链接:https://www.haomeiwen.com/subject/dchwlltx.html