Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 515 Bytes

Vue自定义组件Props中接收数组.md

File metadata and controls

40 lines (30 loc) · 515 Bytes

问题

报错

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

报错信息

[Vue warn]: Invalid default value for prop "showcontent": Props with type Object/Array must use a factory function to return the default value.

问题解决

props: {
    showcontent: {
      type: Array,
      default: function () { return [] }
    },
}

ES6

props: {
    showcontent: {
      type: Array,
      default: () => []
    },
}