Invalid default value for prop 'XXX': props with type object/array must use a factory func


vue组件在props中 给默认值的时候  容易出现这个错误。

解决办法:

default 给默认值是object/array 类型的时候,应该使用function函数return返回默认值:

错误写法:

props:{
  files:{
    type:Array,
    default:[]    
    }      
}

正确写法:

props:{
  files:{
    type:Array,
    default:()=>{ return [] }    
    }      
}
vue