wx.onLocationChange搭配wx.startLocationUpdate的使用方法

675 阅读1分钟

wx.startLocationUpdate({
       success(rm) {
              const _locationChangeFn = function(res) {
                     //可以得到经纬度
                    console.log('定位成功', res)
                     wx.offLocationChange(_locationChangeFn)
                 }
              wx.onLocationChange(_locationChangeFn)
        },
      fail(error) {
          console.log("开始定位失败", error);
        }
 })