vue H5 调用微信API 定位

vue 的H5 项目 获取定位 使用微信API  微信公众号配置,及公共方法可参考上篇文章 前三步

 https://www.cnblogs.com/lq2333/p/16646222.html

接口列表中增加 getLocation

jsApiList: ["checkJsApi","getLocation","scanQRCode"] // 必填,需要使用的JS接口列表。 

直接上定位代码

const getLocation = () => {
  wxConfig(proxy.$wx, () => {
         proxy.$wx.getLocation({
         type: 'gcj02',
         success: function(res) {
           longitude.value = res.longitude;
           latitude.value = res.latitude;
       }
    });
  });
}

OK喽。

posted @ 2022-09-01 15:13  金陵彭于晏  阅读(222)  评论(0编辑  收藏  举报