坑點:
uniapp的button按鈕open-type有launchApp,打開APP的功能,但是場景有使用限制,具體參考官方文檔(https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/launchApp.html)
我的寫法:
<template>
<view>
open by map app
</view>
</template>
<script>
export default {
onLoad() {
uni.getLocation({
success: res => {
console.log('location success', res)
uni.openLocation({
latitude: res.latitude,
longitude: res.longitude,
scale: 18
})
}
})
}
}
</script>
<style lang="scss">
</style>
只要調用該接口(uni.openLocation()),就會自動打開一個新的頁面,點擊右下角綠標可以看到高德地圖,騰訊地圖等。