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

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

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