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>
相关推荐
iOS阿玮35 分钟前
社交的本质是价值交换,请不要浪费别人的时间。
uni-app·app·apple
monika_yu1 小时前
uniapp 开发ios, xcode 提交app store connect 和 testflight内测
uni-app
大阳光男孩3 小时前
Vue3 + UniApp 蓝牙连接与数据发送(稳定版)
uni-app
八月林城18 小时前
echarts在uniapp中使用安卓真机运行时无法显示的问题
android·uni-app·echarts
哈贝#18 小时前
vue和uniapp聊天页面右侧滚动条自动到底部
javascript·vue.js·uni-app
iOS阿玮20 小时前
苹果2024透明报告看似更加严格的背后是利好!
uni-app·app·apple
邹荣乐1 天前
微信小程序动态tabBar实现:基于自定义组件,灵活支持不同用户角色与超过5个tab自由组合
前端·微信小程序·uni-app
不吃糖葫芦31 天前
App使用webview套壳引入h5(三)——解决打包为app后在安卓机可物理返回但是在苹果手机无法测滑返回的问题
uni-app·webview
半兽先生1 天前
uniapp微信小程序视频实时流+pc端预览方案
微信小程序·uni-app·音视频
胡斌附体2 天前
uniapp路由跳转toolbar页面
小程序·uni-app·switch·路由·type·uview-ui