公众号wx.getLocation成功了之后还是执行fail

这是一个公众号,为了测试用户未开启定位给一个提示,用了fail。当用户未开启时,显示时正常的,给个toast提示,开启之后从success里继续运行,也是成功的,只是代码还是会执行toast,新手机开启定位进入时不会出现toast的,所以在想是不是缓存

getLocationa() {
      var that=this;
      wx.getLocation({
        type: "wgs84", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
        success: function(res) {
          var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
          var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180
          var speed = res.speed; // 速度,以米/每秒计
          var accuracy = res.accuracy; // 位置精度
          that.getPostion(latitude,longitude);
          console.log(22222222,res)
        },
        fail: function(res){
          cosonsole.log(11111111,res);
          that.showLoading=false;
          that.$vux.toast.show({
            text: "获取定位失败,请开启定位,重新进入",
            type: 'text',
          })
        },
      });
    },
阅读 1.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题