uniapp跳轉內部html 使用webview
1、首先在根目錄創建hybrid 文件夾,創建html子文件夾
2、創建包含webview的vue文件,在pages.json內寫入路徑
文件中包uniapp如何與html 傳值
核心
html中可以使用uniapp api 需使用 document.addEventListener('UniAppJSBridgeReady', function() {
uniapp.跳轉方法
});
html向uniapp vue 傳值
document.addEventListener('UniAppJSBridgeReady', function() {
uni.postMessage({
data: {
此處和小程序一樣
}
});
uni.navigateBack({
delta:1
})
});
uniapp接受值
<web-view src="/hybrid/html/local.html" @message="handleMessage"></web-view>
<script>
export default {
methods: {
handleMessage(evt) {
console.log(evt.detail.data)
// uni.('接收到的消息:' + JSON.stringify(evt.detail.data));
}
}
}
</script>
地圖展示也要使用webview 路徑可以使用該路徑 只需修改你的 lat lng
'http://api.map.baidu.com/geocoder?location='+option.lat+','+option.lng+'&coord_type=gcj02&output=html&src=webapp.baidu.openAPIdemo'
點擊地圖獲取地區的名字
map.addEventListener("onclick", function(e){
geoc.getLocation(e.point, function(rs){
var addComp = rs.addressComponents;
alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
});
});
文章轉載至:https://www.juchengvi.com/looknews/104