Type of the default value for ‘data’ prop must be a function
在写成如下形式代码时,ESLint会报Type of the default value for ‘data’ prop must be a function。
意思是:prop的默认值data必须是一个函数。
一、错误示范
props: {
data: {
type: Array,
default: []
}
}
二、解决办法
1.方式一
props: {
data: {
type: Array,
default: function () { return [] }
}
}
2.方式二(ES6 箭头函数)
props: {
data: {
type: Array,
default: () => []
}
}
还没有评论,来说两句吧...