YingXingAI/pages/webview/index.vue

33 lines
635 B
Vue
Raw Normal View History

2025-06-30 14:43:02 +08:00
<template>
<view>
<u-navbar :title="title" :border-bottom="false"></u-navbar>
<web-view :src="url" @message="handleMessage"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
url: "",
title: "",
};
},
onLoad(options) {
// 接收传入的URL参数
if (options.data) {
const data = JSON.parse(decodeURIComponent(options.data));
this.url = data.url;
this.title = data.name;
}
},
methods: {
handleMessage(event) {
// 处理web-view发送的消息
console.log("来自网页的消息", event.detail);
},
},
};
</script>