ESLint prefer-reflect 错误

ESLint prefer-reflect error

我遇到了 ESLint 的问题

这是我的函数:

test(e) {
    const target = [].slice.call(e.target.parentNode.children).indexOf(e.target)
    this.goToItem(target)
}

这是 ESLint 告诉我的:

Avoid using Function.prototype.call, instead use Reflect.apply

我试图找到一些东西来帮助我进入文档 http://eslint.org/docs/rules/prefer-reflect。但是我不知道把切片放在哪里...

请问如何解决这个错误?

The MDN pageReflect.apply() 上为您提供了有关如何使用它的更多信息:

test(e) {
    const target = Reflect.apply([].slice, e.target.parentNode.children, []).indexOf(e.target)
    this.goToItem(target)
}