html页面返回参数:
uni.webView.postMessage({data: this.center})
vue页面接收参数:
<web-view id="web-view" src="/static/html/bmap.html" ref="webview" class="map" @message="handlePostMessage">
methods: {
// webview向外部发送消息
handlePostMessage({detail}){
// 触发表单页面修改事件
uni.$emit('getUserGeolocation',detail.data[0])
uni.navigateBack()
},
}
上一级vue获得参数:
methods: {
location() {
// 监听getUserGeolocation触发的数据
uni.$on('getUserGeolocation', ({
lat,
lng,
address
}) => {
this.installParam.latitude = lat
this.installParam.longitude = lng
this.installParam.address = address
})
uni.navigateTo({
url: '/pages/home/map/location'
})
},
}