54 lines
1.1 KiB
Vue
Raw Normal View History

2025-05-22 16:37:43 +08:00
<template>
<view v-if="params.url">
2025-05-30 16:23:13 +08:00
<web-view :src="`${params.url}`" @message="handleMessage"></web-view>
2025-05-22 16:37:43 +08:00
<u-loading-page :loading="loading"></u-loading-page>
</view>
</template>
<script>
export default {
data () {
return {
loading: true,
params: {}
}
},
props: {
src: {
type: [String],
default: null
}
},
onLoad (event) {
const { url, ...res } = event;
this.params = {
url: decodeURIComponent(url),
res
};
if (event.title) {
uni.setNavigationBarTitle({
title: event.title
})
};
setTimeout(() => {
this.loading = false;
}, 1000);
},
2025-05-30 16:23:13 +08:00
methods: {
handleMessage(e) {
console.log('[DEBUG] Webview收到消息:', e.detail);
// 处理接收到的消息
if (e.detail && e.detail.data) {
const data = e.detail.data;
console.log('[DEBUG] 消息数据:', data);
// 如果消息中包含type和data字段
if (data.type && data.data) {
console.log('[DEBUG] 消息类型:', data.type);
console.log('[DEBUG] 消息内容:', data.data);
}
}
}
}
2025-05-22 16:37:43 +08:00
}
</script>