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

2021-04-19  本文已影响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;
上一篇 下一篇

猜你喜欢

热点阅读