<script>
import amap from "@/static/js/amap-wx.130.js"
export default {
data() {
return {
href: 'https://uniapp.dcloud.io/component/README?id=uniui',
amapPlugin: null,
key: '04a869649416ced7f9f561b082f57877'
}
},
onLoad() {
this.amapPlugin = new amap.AMapWX({
//高德地图小程序KEY,替换为自己的KEY,参考:http://ask.dcloud.net.cn/article/35070
//https://lbs.amap.com/api/wx/gettingstarted
key: this.key
});
console.log(this.amapPlugin)
console.log(this.amapPlugin.getRegeo)
//定位地址
this.amapPlugin.getRegeo({
success: (res) => {
console.log(adData)
this.tian(adData)
}
});
},
methods: {
getAddress() {
uni.showLoading({
title: '获取信息中'
});
debugger
// 成功获取位置
this.amapPlugin.getRegeo({
success: (data) => {
console.log(data, '当前定位')
uni.hideLoading();
},
// 获取位置失败
fail: (err) => {
uni.showToast({
title: "获取位置失败,请重启小程序",
icon: "error"
})
}
});
}
}
}
</script>
0 个回复