通過你獲取的key放到項目manifest.json里面,對應填寫你所需要的key值,還有高德用戶名
用戶名:
key值的位置:
代碼:
html:
<view class="intList pdNone"><view class="label">詳細地址</view><uni-easyinput @iconClick="goLocalAddress" placeholder="請點擊圖標獲取詳細地址" v-model="form.address" />
</view>
js:
goLocalAddress() {uni.showLoading({title: '獲取中...'})let _this = thisuni.getLocation({geocode: true,type: 'gcj02',success: (res) => {uni.hideLoading()this.form.address = res.address.poiName || res.address.streetthis.form.longitude = res.longitudethis.form.latitude = res.latitude},fail: function(e) {uni.hideLoading()uni.getNetworkType({success: (res) => {},fail: () => {uni.showModal({content: '獲取失敗!',showCancel: false})}})uni.showToast({title: JSON.stringify(e),icon: 'none'});}});
},
效果:點擊圖標可直接獲取當前位置