Uniapp:navigator(页面跳转)

目录


一、基本概述

页面跳转。该组件类似HTML中的<a>组件,但只能跳转本地页面。目标页面必须在pages.json中注册。

二、属性说明

属性名 类型 默认值 说明 平台差异说明
url String 应用内的跳转链接,值为相对路径或绝对路径,如:".../first/first","/pages/first/first",注意不能加 .vue 后缀
open-type String navigate 跳转方式

open-type 有效值

说明 平台差异说明
navigate 对应 uni.navigateTo 的功能,保留当前页面,跳转到应用内的某个页面
redirect 对应 uni.redirectTo 的功能,关闭当前页面,跳转到应用内的某个页面
reLaunch 对应 uni.reLaunch 的功能,关闭所有页面,打开到应用内的某个页面 抖音小程序与飞书小程序不支持

三、具体使用

html 复制代码
<template>
  <view v-for="item in dataList" :key="item.fl">
    <page-head :title="item.fl"></page-head>
    <view class="uni-padding-wrap uni-common-mt uni-mt-common">
      <view class="uni-flex common-class" :style='{"background-color": children.color}' v-for="children in item.children" :key="children.value">
        <navigator :url="children.value"><text>{{children.label}}</text></navigator>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        dataList: [
          {
            fl: "视图容器",
             children: [
               {label: "view", value: "/pages/component/view/view", color: "#c0f5f9",},
               {label: "scroll-view", value: "/pages/component/scroll-view/scroll-view", color: "#75f4c4",},
               {label: "swiper", value: "/pages/component/swiper/swiper", color: "#f2b174",},
              ],
          },
        ]
      }
    },
    methods: {
      
    }
  }
</script>

<style>
  .uni-mt-common {
    display: flex;
    flex-direction: row;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    font-size: 14rpx;
    color: #333;
  }
  .common-class {
    margin-right: 10rpx;
    margin-bottom: 10rpx;
    width: 150rpx;
    height: 150rpx;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-align-items: center;
    align-items: center;
  }
</style>
相关推荐
2501_916007473 小时前
iOS性能调试工具终极指南,从系统底层到多端协同的全方位优化实践(2025版)
android·ios·小程序·https·uni-app·iphone·webview
2501_915921433 小时前
iOS崩溃日志深度分析与工具组合实战,从符号化到自动化诊断的完整体系
android·ios·小程序·uni-app·自动化·cocoa·iphone
2501_9160088910 小时前
没有源码如何加密 IPA 实战流程与多工具组合落地指南
android·ios·小程序·https·uni-app·iphone·webview
LXA080912 小时前
UniApp 小程序中使用地图组件
小程序·uni-app·notepad++
QuantumLeap丶14 小时前
《uni-app跨平台开发完全指南》- 07 - 数据绑定与事件处理
vue.js·ios·uni-app
2501_9159090618 小时前
Flutter 应用怎么加固,多工具组合的工程化实战(Flutter 加固/Dart 混淆/IPA 成品加固/Ipa Guard + CI)
android·flutter·ios·ci/cd·小程序·uni-app·iphone
xiaaaa.z21 小时前
macos HbuildX 使用cli脚本创建uniapp 运行时报错“cli项目运行依赖本地的Nodejs环境,请先安装并配置到系统环境变量后重试。”
macos·uni-app
2501_9159090621 小时前
深入理解HTTPS和HTTP的区别、工作原理及安全重要性
安全·http·ios·小程序·https·uni-app·iphone
Q_Q5110082852 天前
python+uniapp基于微信小程序的垃圾分类信息系统
spring boot·python·微信小程序·django·flask·uni-app·node.js
你的眼睛會笑2 天前
uniapp 鸿蒙元服务 真机调试流程指南
华为·uni-app·harmonyos