html52.com
我爱小程序-开发者交流社区

wx.onLocationChange获取经纬度为什么很慢,5到6s才成功?

getLocationFun() {

wx.showLoading({

title: '加载中...',

mask: true,

})

let that = this;

// return new Promise((resolve, reject) => {

let _locationChangeFn = (res) => {

console.log('location change', res)

wx.hideLoading()

that.lon = res.longitude;

that.lat = res.latitude;

that.searchClick(); // 刷新列表

wx.offLocationChange(_locationChangeFn)

}

wx.startLocationUpdate({

success: (res) => {

console.log(res);

wx.onLocationChange(_locationChangeFn)

// resolve()

},

fail: (err) => {

console.log('获取当前位置失败', err)

wx.hideLoading()

// reject()

}

})

// })

},

这是监听经纬度代码,获取到经纬度后刷新列表,列表接口本身是很快的,请问有什么优化方案

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付