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

小程序getLocation无法拉起授权窗口

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.getLocation 微信iOS客户端 7.0.12 2.11.0

小程序在体验版中无法正常拉起位置信息授权框,但是真机调试以及工具中均可以正常拉起。体验版返回的errMsg提示"getLocation:fail require permission desc"。但是app.json中已正常配置permission信息。

app.json:

"permission": {
    "scope.userLocation": {
      "desc""你的位置信息将用于小程序定位"
    }
  },

js:

wx.getLocation({
      type'gcj02',
      success: res => {
        that.getNowSituation(res)
      },
      fail: res => {
        console.log(res)
        wx.getSetting({
          success: (res) => {
            if (!res.authSetting['scope.userLocation']) {
              wx.hideLoading()
              wx.showModal({
                title: '提示',
                content: '尚未授权获取位置信息,请先授权',
                confirmText: '前往授权',
                success(res) {
                  if (res.confirm) {
                    wx.openSetting({
                      complete: (res) => {
                        wx.getLocation({
                          type'gcj02',
                          success: res => {
                            that.getNowSituation(res)
                          }
                        })
                      },
                    })
                  } else if (res.cancel) {
                    wx.navigateBack()
                  }
                }
              })
            }
          },
        })
      }
    })

体验版提示:

{errMsg:"getLocation:fail require permission desc"}

评论 抢沙发

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

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

云免签H5支付