Parsing error: Expression expected.

项目中 eslint 报此错误,网上没找到解决方法,自己摸索一番已解决。

    // 省略无用代码...
    hammer.on('doubletap', e => {
      const c = this.rawCenter(e)
      this.zoomAround(2, c.x, c.y)
    })

编辑器在 const 处提示报错, 将花括号里的代码提取到单独的函数中,再引用此函数就好了

  // 省略无用代码...
  doubletapHandle(e) {
    const c = this.rawCenter(e)
    this.zoomAround(2, c.x, c.y)
  }
  hammer.on('doubletap', e => this.doubletapHandle)

猜你喜欢

转载自www.cnblogs.com/teemwu/p/12807960.html