props default 数组/对象的默认值应当由一个工厂函数返回

export default {
props: {

slides:{
  type:Array,
  default:[]
}

},这是我的代码

报错是Invalid default value for prop "slides": Props with type Object/Array must use a factory function to return the default value.

// 数组/对象的默认值应当由一个工厂函数返回

// 这是文档里的例子,返回对象
propE: {
  type: Object,
  default: function () {
    return { message: 'hello' }
  }
},
// 返回数组的默认值
proE: {
    type: Array,
    default: function () {
        return []
    }
}
原文地址:https://www.cnblogs.com/mmzuo-798/p/9754394.html