iOS 在开发者工具中,远程调式,预览和体验版的区别
发布于 5 年前 作者 ntao 19316 次浏览 来自 问答

在开发者工具中,iOS远程调试使用wx.chooseLocation和wx.openLocation都可以,但是在预览模式和体验版本中,wx.chooseLocation只有第一次有效,后面进去的都无效,而wx.openLocation打不开,同一个手机,同一段代码,只是模式不同,这是为什么?微信版本:6.6.6, 手机:苹果6P

onLoad: function (options) {
  var that = this
  var param = JSON.parse(options.param)
  console.log('onLoad begin')
  if (param.latitude && param.longitude) {
    console.log('打开地图', +param.latitude, +param.longitude)
    wx.openLocation({
      latitude: +param.latitude,
      longitude: +param.longitude,
      address: param.address,
      fail: function () {
        console.log('地图打开失败')
        wx.showToast({
          icon: 'none',
          title: '地图打开失败',
          complete: function () {
            var time = setTimeout(function () {
              clearTimeout(time)
              time = null
              wx.navigateBack()
            }, 500)
          }
        });
      },
      success: function () {
        console.log('地图打开成功')
      },
      complete: function () {
        that.setData({
          showCheckPage: true
        })
      }
    })
  } else {
    console.log('地图选择打开')
    wx.chooseLocation({
      success: function (res) {
        console.log('地图选择成功')
      },
      cancel: function () {
        console.log('取消发送')
        wx.showToast({
          icon: 'none',
          title: '取消发送',
          complete: function () {
            var time = setTimeout(function () {
              clearTimeout(time)
              time = null
              wx.navigateBack()
            }, 500)
          }
        });
      }
    })
  }
   
},
1 回复

你好,请使用代码片段功能提供可复现的代码片段即可:https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.htm

回到顶部