这个错误报错原因:
此规则旨在防止在计算属性中产生副作用的代码。
解决办法:
使用watch监听属性
listShow() {
if (!this.totalCount) {
return false;
}
if (this.totalCount > 0 && !this.fold) {
return true;
}
return false;
}
watch: {
selectedFoods (newFoods, oldFoods) {
if (newFoods.length === 0) {
this.fold = true;
}
}
}