在写 vue 组件的 props 时,像下面设置默认值,就会出现 eslint 语法报错 :error: Type of the default value for ‘tableData‘ prop must be a function(tableData 属性的默认值必须是函数)。
props: {
tableData: {
type: Array,
default: [],
}
},
如何修改呢?Use Array/Object in props as default value。
props: {
tableData: {
type: Array,
default: () => [],
// 或者 default: function () { return [] }
}
},