微信小程序常见的问题处理措施

1、TabBar 至少包含两项
在这里插入图片描述/2、Json配置文件是非常严格json格式
不允许:注释,键值对单引号,多余逗号,
在这里插入图片描述
3、TabBar配置了,但是看不到
是不是分辨率不够,需要往下滚动查看
Tabbar图片路径写错
在这里插入图片描述
4、小程序中如何获取地理位置并通过小程序展示地址
1.app.json权限配置:

"permission": {
    "scope.userLocation": {
      "desc": "你的位置方便获取最新房源"
    }
  }

2、调用

wx.getLocation({//获取经纬度
   type: 'wgs84',
   success: res => {
      var longitude = res.longitude
      var latitude = res.latitude
     _this.loadCity(longitude, latitude)
   }
})
loadCity: function (longitude, latitude) {//百度api,经纬度转换地址
     var page = this
     wx.request({
       url: 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=......&location=' + latitude + ',' + longitude + '&output=json&coordtype=wgs84ll',
        data: {},
        header: {
          'Content-Type': 'application/json'
        },
        success: function (res) {
          // success 
          console.log(res);
          var city = res.data.result.addressComponent.city;
          console.log("城市为" + city)
          page.setData({ city: city });
        }
    })
  }

5、小程序中调用全局的变量,方法

const app = getApp();
app.globalData.openid = '11111111';//其他page即可引用

猜你喜欢

转载自blog.csdn.net/weixin_48193717/article/details/107944612