坑点:
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()),就会自动打开一个新的页面,点击右下角绿标可以看到高德地图,腾讯地图等。