Vue.js eslint-在我的vue项目中使用数组分解

Vue.js eslint-在我的vue项目中使用数组分解,vue.js,eslint,Vue.js,Eslint,我有这样一行this.report=newVal[0]。我正在看文档,我很困惑 我看到的例子如下 const local = this.propslocal const {local} = this.props 有什么想法吗?看看这个: 此规则强制使用解构,而不是访问 属性通过成员表达式 正如您所看到的示例,您应该更改您的: this.report = newVal[0] 对此,请改为: [this.report] = newVal; 为了让您清楚,如果newVal有4项,并且您希望将前2

我有这样一行
this.report=newVal[0]。我正在看文档,我很困惑

我看到的例子如下

const local = this.propslocal
const {local} = this.props
有什么想法吗?

看看这个:

此规则强制使用解构,而不是访问 属性通过成员表达式

正如您所看到的示例,您应该更改您的:

this.report = newVal[0]
对此,请改为:

[this.report] = newVal;
为了让您清楚,如果
newVal
有4项,并且您希望将前2项存储到不同的变量中,而不是执行以下操作:

const a = newVal[0];
const b = newVal[1];
使用分解结构,您应该执行以下操作:

const [a, b] = newVal;

你为什么要改变这一点?eslint和它有什么关系?你到底有什么问题?b/c我们有一个linter,它抛出
使用数组去结构。eslint(首选去结构)
错误,我已经看了很多例子,但没有弄清楚