用vue写公众号项目,wx.getlocation方法,每次刷新时候,不请求,config也不返回.

  • 用vue写公众号项目,wx.getlocation方法,每次刷新时候,不请求,config也不返回..但是修改保存后就会有,就是不能刷新,请问这是什么问题
mounted () {
    this.probeType = 3
    this.listenScroll = true
    this.map = new window.BMap.Map('baidu')
    this.getLocation() // 调用方法顺序: 先获取当前坐标点,再调用接口数据,再初始化地图,设置设备坐标点.
},
methods: {
    getLocation () {
        let _this = this
        console.log('获取地理位置')
        window.wx.getLocation({
            type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
            success: function (res) {
                _this.posInfor = res
                _this.xyz.latitude = res.latitude
                _this.xyz.longitude = res.longitude
                _this.getData()
            },
            fail: function (err) {
                console.log(err)
            }
        })
    },
}


clipboard.png

  • 如果是页面切入,就可以显示 ,如果是刷新就如上图...

clipboard.png

阅读 5.7k
2 个回答

是不是要写在WeixinJSBridgeReady回调里才能调用

wxsdk 要在真机测试

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题