vue父子组件传值-子组件接收数据复杂数据时注意事项

330 阅读1分钟

warning Prop 'row' requires default value to be set vue/require-default-prop image.png

vue父子组件传值 子组件接收数据时 当数据为复杂数据类型时 需要设置默认值 使用函数返回 简单数据类型只需写默认值即可

  • 数据类型为string,Number,boolean时 只需默认值或省略
 isEdit: {
      type: Boolean
      default:''  //可省略
    }
  • 数据类型为object时
row:{
type:object,
default:()=>{}
}
  • 数据类型为数组Array时
row:{
tupe:Array,
default:()=>[]
}