提交 8326e10f 编写于 作者: DCloud-yinjiacheng's avatar DCloud-yinjiacheng

更新web-view示例

上级 230cf605
<template>
<web-view ref="web-view" class="web-view" src="/hybrid/html/local.html" @message="message" @error="error"
@loading="loading" @loaded="loaded">
@loading="loading" @load="load">
</web-view>
</template>
......@@ -13,23 +13,23 @@
}
},
methods: {
message(event : WebViewMessageEvent) {
console.log(JSON.stringify(event.detail));
message(event : UniWebViewMessageEvent) {
console.log(JSON.stringify(event));
uni.showModal({
content: JSON.stringify(event.detail),
showCancel: false
});
},
error(event : WebViewErrorEvent) {
error(event : UniWebViewErrorEvent) {
this.loadError = true
console.log(JSON.stringify(event.detail));
console.log(JSON.stringify(event));
},
loading(event : WebViewLoadingEvent) {
console.log(JSON.stringify(event.type));
loading(event : UniWebViewLoadingEvent) {
console.log(JSON.stringify(event));
},
loaded(event : WebViewLoadedEvent) {
load(event : UniWebViewLoadEvent) {
this.loadFinish = true;
console.log(JSON.stringify(event.type));
console.log(JSON.stringify(event));
}
}
}
......
<template>
<view class="uni-flex-item">
<web-view id="web-view" class="uni-flex-item" :src="src" :webview-styles="webview_styles" @message="message"
@error="error" @loading="loading" @loaded="loaded" @download="download">
@error="error" @loading="loading" @load="load" @download="download">
</web-view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-input-v">
......@@ -58,27 +58,27 @@
nativeToWeb() {
this.webviewContext?.evalJS("alert('hello uni-app x')");
},
message(event : WebViewMessageEvent) {
message(event : UniWebViewMessageEvent) {
console.log(JSON.stringify(event));
},
error(event : WebViewErrorEvent) {
error(event : UniWebViewErrorEvent) {
this.loadError = true
console.log(JSON.stringify(event));
},
loading(event : WebViewLoadingEvent) {
loading(event : UniWebViewLoadingEvent) {
console.log(JSON.stringify(event));
},
loaded(event : WebViewLoadedEvent) {
load(event : UniWebViewLoadEvent) {
console.log(JSON.stringify(event));
},
download(event : WebViewDownloadEvent) {
download(event : UniWebViewDownloadEvent) {
console.log(JSON.stringify(event));
uni.showModal({
content: "下载链接: " + event.detail.url + "\n文件大小: " + event.detail.contentLength / 1024 + "KB",
showCancel: false
});
},
confirm(event : InputConfirmEvent) {
confirm(event : UniInputConfirmEvent) {
console.log(JSON.stringify(event));
let url = event.detail.value;
if (!url.startsWith('https://') && !url.startsWith('http://')) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册