uniapp vue3 点击跳转外部网页
需求
项目登录界面有隐私协议,用户点击对应的协议,跳转到对应的外部网页。

问题
使用uni.navigateTo跳转后,界面未加载上。
解决思路
跳转逻辑参考:

承载网页的容器:

代码
login.vue 登录页面
<template>...<text class="text">我已阅读并同意<text class="agreement" @tap.stop="onUserAgreement">《用户协议》</text>...
</template>
<script setup>...const onUserAgreement = () => {const url = 'https://*****' // 对应的网址uni.navigateTo({url: '/webview/webview?url=' + encodeURIComponent(url)})}...
</script >
webview.vue 承载网页的页面
<template><view class="container"><web-view :src="url"></web-view></view>
</template>
<script setup>import { ref, getCurrentInstance } from 'vue'import { onLoad } from '@dcloudio/uni-app'const { proxy } = getCurrentInstance()onLoad((option) => {url.value = decodeURIComponent(option.url)})const url = ref('')
</script><style scoped lang='scss'>.container {position: relative;width: 100%;min-height: 100vh;padding: 10px;box-sizing: border-box;background-color: #fff;}
</style>
