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


问题

报错

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: () => []
    },
}

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM