Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ESLint偏好反射错误_Javascript_Ecmascript 6_Eslint - Fatal编程技术网

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的示例。