当前位置: 首页> 健康> 知识 > uniApp跳转外链

uniApp跳转外链

时间:2025/7/13 15:56:51来源:https://blog.csdn.net/m0_38007556/article/details/140870136 浏览次数:0次

创建一个新的页面,在该页面中使用web-view组件加载外部URL:pages/web-view/web-view

<template><view><uni-list><uni-list-itemtitle="打开外部链接"@click="openExternalLink"></uni-list-item></uni-list></view>
</template><script>
export default {methods: {openExternalLink() {window.open('https://super.xiaoxilao.com/', '_blank');}}
}
</script><style>
/* 你的样式 */
</style>

在我们当前需要点击跳转的页面,增加点击事件,跳转到你创建的web-view页面,并传递URL参数:例如:/pages/index/index

<template><view><uni-list><uni-list-itemtitle="打开外部链接"@click="openExternalUrl('https://super.xiaoxilao.com/')"></uni-list-item></uni-list></view>
</template><script>
export default {methods: {openExternalUrl(url) {uni.navigateTo({url: `/pages/web-view/web-view?url=${encodeURIComponent(url)}`});}}
}
</script><style>
/* 你的样式 */
</style>

关键字:uniApp跳转外链

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: