uniApp跳转外链

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

javascript 复制代码
<template>
  <view>
    <uni-list>
      <uni-list-item
        title="打开外部链接"
        @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

javascript 复制代码
<template>
  <view>
    <uni-list>
      <uni-list-item
        title="打开外部链接"
        @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>
相关推荐
狂奔的sherry38 分钟前
一次由 mount 引发的 Linux 文件系统“错觉”
linux·运维·服务器
豆浆煮粉2 小时前
Ubuntu虚拟机对USB设备无响应且Windows主机设备管理器显示警告
windows·ubuntu
Python私教3 小时前
HermesAgent 终端工具 Windows 兼容性修复实战:两个 Bug 的排查与解决
windows·bug
℡終嚸♂6803 小时前
n8n 未初始化接管到读取 Flag Writeup
服务器·web安全·web·n8n
风翼靓崽4 小时前
linux命令杂记 - 杂乱无章
linux·运维·服务器
spencer_tseng4 小时前
redis.windows.conf 2026.04.27
windows·redis
solihawk4 小时前
服务器内存被谁“偷”走了?
服务器·数据库
德彪稳坐倒骑驴4 小时前
SQL连续登录问题
服务器·数据库·sql
校羽干5 小时前
ubuntu22.04 安装卸载更新 ollama
运维·服务器
淘矿人5 小时前
2026年4月-DeepSeek V4 vs GPT-5.5深度对比测评:weelinking一键切换实测
服务器·数据库·人工智能·python·gpt·学习·php