41 lines
963 B
Vue
41 lines
963 B
Vue
<template>
|
|
<view>
|
|
<!-- web-view 组件用于加载网页 -->
|
|
<web-view :src="webUrl" @message="onMessage"></web-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
// 外部网页的URL
|
|
webUrl: ''
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
console.log(options)
|
|
this.webUrl = options.url
|
|
},
|
|
methods: {
|
|
// onLoad(event) {
|
|
// console.log('Webview loaded:', event);
|
|
// // 检查 event.detail 是否存在并获取新 URL
|
|
// if (event && event.detail && event.detail.src) {
|
|
// this.webUrl = event.detail.src;
|
|
// console.log('New URL:', this.webUrl);
|
|
// } else {
|
|
// console.warn('Load event does not contain expected src property');
|
|
// }
|
|
// },
|
|
onError(event) {
|
|
console.error('Error loading webview:', event);
|
|
// 你可以根据 event.detail 进一步处理具体错误
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
/* 样式可以根据需要自定义 */
|
|
</style> |