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>
相关推荐
q_191328469531 分钟前
基于Springboot2+Vue2+uniapp的单商家在线点餐外卖小程序
vue.js·spring boot·mysql·小程序·uni-app·计算机毕业设计
2501_915918411 小时前
iOS CPU 使用率深度分析,多工具协同定位高占用瓶颈的工程化方法
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 小时前
如何防止资源文件被替换?一套针对 iOS App 的多层资源安全方案
android·安全·ios·小程序·uni-app·iphone·webview
你真的可爱呀7 小时前
uniapp+vue3项目中的常见报错情况以及解决方法
前端·vue.js·uni-app
郑州光合科技余经理10 小时前
同城系统海外版:一站式多语种O2O系统源码
java·开发语言·git·mysql·uni-app·go·phpstorm
博客zhu虎康11 小时前
uniApp 开发
arcgis·uni-app
郑州光合科技余经理13 小时前
基于PHP:海外版同城O2O系统多语言源码解决方案
java·开发语言·git·spring cloud·uni-app·php·uniapp
怀君17 小时前
Uniapp——开发Android插件教程
android·uni-app
2501_915921431 天前
混合开发应用安全方案,在多技术栈融合下构建可持续、可回滚的保护体系
android·安全·ios·小程序·uni-app·iphone·webview
q_19132846951 天前
基于SpringBoot2+Vue2+uniapp的考研社区论坛网站及小程序
java·vue.js·spring boot·后端·小程序·uni-app·毕业设计