提交 4bee2279 编写于 作者: H hdx

webview: 框架已支持,移除临时写法

上级 31932989
......@@ -54,7 +54,7 @@
switch (action) {
case 'switchTab':
uni.switchTab({
url: '/pages/tabBar/API/API'
url: '/pages/tabBar/API'
});
break;
case 'reLaunch':
......
<template>
<view class="uni-flex-item">
<web-view ref="web-view" class="uni-flex-item" src="/hybrid/html/local.html" @message="message" @error="error"
@loading="loading" @loaded="loaded">
</web-view>
</view>
<view class="uni-flex-item">
<web-view ref="web-view" class="uni-flex-item" src="/hybrid/html/local.html" @message="message" @error="error"
@loading="loading" @loaded="loaded">
</web-view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
message(event : WebViewMessageEvent) {
console.log(JSON.stringify(event.detail));
const data = event.detail.data;
if (data == null) return;
switch (data['action']) {
case 'navigateTo':
uni.navigateTo({
url: data['url'] as string
});
break;
case 'redirectTo':
uni.redirectTo({
url: data['url'] as string
});
break;
case 'switchTab':
uni.switchTab({
url: data['url'] as string
});
break;
case 'reLaunch':
uni.reLaunch({
url: data['url'] as string
});
break;
case 'navigateBack':
uni.navigateBack({
delta: data['delta'] as number
});
break;
default:
uni.showModal({
content: JSON.stringify(event.detail),
showCancel: false
});
break;
}
},
error(event : WebViewErrorEvent) {
console.log(JSON.stringify(event.detail));
},
loading(event : WebViewLoadingEvent) {
console.log(JSON.stringify(event.type));
},
loaded(event : WebViewLoadedEvent) {
console.log(JSON.stringify(event.type));
}
}
}
export default {
data() {
return {
}
},
methods: {
message(event : WebViewMessageEvent) {
console.log(JSON.stringify(event.detail));
},
error(event : WebViewErrorEvent) {
console.log(JSON.stringify(event.detail));
},
loading(event : WebViewLoadingEvent) {
console.log(JSON.stringify(event.type));
},
loaded(event : WebViewLoadedEvent) {
console.log(JSON.stringify(event.type));
}
}
}
</script>
<style>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册