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>
相关推荐
鼎讯信通1 分钟前
高性能射频信号模块 全方位守护能源设备稳定运行与高效检测
服务器·人工智能·能源
你是个什么橙5 分钟前
Linux 远程桌面访问和管理——VNC服务器
linux·运维·服务器
nhfc996 分钟前
whisper.cpp编译
linux·运维·服务器
深圳恒讯23 分钟前
越南服务器 ping 值多少?
运维·服务器
ShineWinsu23 分钟前
对于Linux:内核是如何组织管理IPC资源的解析
linux·服务器·c++·面试·笔试·线程·ipc
caimouse27 分钟前
Reactos 第 5 章 进程与线程 — 5.3 系统调用 NtCreateProcess()
服务器·开发语言
X_szxj28 分钟前
Windows安装liboqs库
windows·github
caimouse1 小时前
Reactos 第 5 章 进程与线程 — 5.1 概述
c语言·windows·架构
feng_you_ying_li1 小时前
Linux之线程同步:条件变量和两种生产消费模型
linux·运维·服务器
玖釉-1 小时前
nvpro_core2 详解:NVIDIA Vulkan / OpenGL 图形样例背后的现代 C++ 基础库
c++·windows·图形渲染