一、先看需求,进入页面中,自动定位并填充对应值。
二、自行注册账号、获取密钥,非重点。
三、在index.html中引入
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=你的秘钥&plugin=AMap.Geocoder"></script>
四、然后在页面中使用
data() {
return {
form: {
lng: '',
lat: '',
address: '',
}
}
}
created() {
this.getLocation();
},
methods: {
// 高德定位
getLocation() {
const self = this;
AMap.plugin("AMap.Geolocation",