Javascript ESLint偏好反射错误
我对埃斯林特有意见 以下是我的功能:Javascript ESLint偏好反射错误,javascript,ecmascript-6,eslint,Javascript,Ecmascript 6,Eslint,我对埃斯林特有意见 以下是我的功能: test(e) { const target = [].slice.call(e.target.parentNode.children).indexOf(e.target) this.goToItem(target) } 以下是ESLint告诉我的: 避免使用Function.prototype.call,而是使用Reflect.apply 我想找点东西帮我找到医生。但是我不知道把切片放在哪里 请说明如何解决此错误?关于Reflect.ap
test(e) {
const target = [].slice.call(e.target.parentNode.children).indexOf(e.target)
this.goToItem(target)
}
以下是ESLint告诉我的:
避免使用Function.prototype.call,而是使用Reflect.apply
我想找点东西帮我找到医生。但是我不知道把切片放在哪里
请说明如何解决此错误?关于Reflect.apply的内容提供了有关如何使用它的更多信息:
test(e) {
const target = Reflect.apply([].slice, e.target.parentNode.children, []).indexOf(e.target)
this.goToItem(target)
}
实际上,为什么不只是Array.frome.target.parentNode.children呢?更清楚。你链接到的页面显示了大量如何使用Reflect的示例。