问题描述:使用 eslint 出现 Expected the Promise rejection reason to be an Error 的问题。

handleGeocoder (address) {
  return new Promise((resolve, reject) => {
    geocoder.getLocation(address, (status, result) => {
      if (status === 'complete' && result.geocodes.length) {
        const position = result.geocodes[0].location
        resolve({
          lat: position.lat,
          lng: position.lng,
        })
      } else {
        reject('地址解析失败, 请刷新重试')
      }
    })
  })
},

将上述 reject 返回的信息,改成  promise.reject(new Error(‘地址解析失败, 请刷新重试’)),相当于 promise.reject 中传入一个 Error 对象。