vue/no-side-effects-in-computed-properties

Unexpected side effect in “listShow” computed property vue/no-side-effects-in-computed-properties

报错原因

if (!this.totalCount) {
	this.isShow = false
	return false
}

在ESLint的情况下,computed中不能直接修改data中的数据

解决方法

把修改data数据写成一个方法,在computed中调用该方法

//方法
updateIsShow() {
	this.isShow = false
}
//computed中
if (!this.totalCount) {
	this.updateIsShow()
	return false
}
发布了34 篇原创文章 · 获赞 0 · 访问量 612

猜你喜欢

转载自blog.csdn.net/qq_44631273/article/details/104811969
今日推荐