首页 > 其他分享 >uni-app页面跳转传递参数

uni-app页面跳转传递参数

时间:2022-09-03 10:23:48浏览次数:82  
标签:hover 16 app 29 跳转 uni type

uni-app页面跳转传递参数

首先来看看官网给的介绍:

页面跳转。

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

该组件的功能有API方式,另见:https://uniapp.dcloud.io/api/router?id=navigateto(opens new window)

属性说明

属性名 类型 默认值 说明 平台差异说明
url String 应用内的跳转链接,值为相对路径或绝对路径,如:"../first/first","/pages/first/first",注意不能加 .vue 后缀
open-type String navigate 跳转方式
delta Number 当 open-type 为 'navigateBack' 时有效,表示回退的层数
animation-type String pop-in/out 当 open-type 为 navigate、navigateBack 时有效,窗口的显示/关闭动画效果,详见:窗口动画 App
animation-duration Number 300 当 open-type 为 navigate、navigateBack 时有效,窗口显示/关闭动画的持续时间。 App
hover-class String navigator-hover 指定点击时的样式类,当hover-class="none"时,没有点击态效果
hover-stop-propagation Boolean false 指定是否阻止本节点的祖先节点出现点击态 微信小程序
hover-start-time Number 50 按住后多久出现点击态,单位毫秒
hover-stay-time Number 600 手指松开后点击态保留时间,单位毫秒
target String self 在哪个小程序目标上发生跳转,默认当前小程序,值域self/miniProgram 微信2.0.7+、百度2.5.2+、QQ

open-type 有效值

说明 平台差异说明
navigate 对应 uni.navigateTo 的功能
redirect 对应 uni.redirectTo 的功能
switchTab 对应 uni.switchTab 的功能
reLaunch 对应 uni.reLaunch 的功能 字节跳动小程序与飞书小程序不支持
navigateBack 对应 uni.navigateBack 的功能
exit 退出小程序,target="miniProgram"时生效 微信2.1.0+、百度2.5.2+、QQ1.4.7+

注意

  • 跳转tabbar页面,必须设置open-type="switchTab"
  • navigator-hover 默认为 {background-color: rgba(0, 0, 0, 0.1); opacity: 0.7;}, <navigator> 的子节点背景色应为透明色。
  • navigator-open-type属性 如果使用对应的值,则对应值的功能会高于对应跳转路径。
  • app-nvue 平台只有纯nvue项目(render为native)才支持 <navigator>。非render为native的情况下,nvue暂不支持navigator组件,请使用API跳转。
  • app下退出应用,Android平台可以使用plus.runtime.quit (opens new window)。iOS没有退出应用的概念。
  • uLink组件 (opens new window)是navigator组件的增强版,样式上自带下划线,功能上支持打开在线网页、其他App的schema、mailto发邮件、tel打电话。

案例

fm是一个数组,里面存放的是数个对象,每一个对象就是一个表单信息,所以要展示所有表单信息,就用v-for将所有表单信息都遍历出来。但是又要设计每个表单都可以实现跳转,展示表单详情;所以页面跳转时就要专递该表单的信息到新页面。传递该表单的主键到新页面,再由接口出查询。

为什么不直接将所有信息直接传递过去呢?

因为URL写法有长度限制!!!!!

<view style="margin-left: 20px; margin-bottom: 10px;" class="body2" v-for="(item,index) in fm">
    <view style="padding: 10px; float: left; width: 70%; height: 100%;">
        <view style="height: 50%;" class="item">
            <text style="font-weight:bold; font-size: 18px;">申请单编号:</text>
            <navigator :url="'./ApplyDetails?bill_code={{item.pk_hi_stapply}}'" hover-class="navigator-hover" >
            <text style="font-size: 15px; font-weight:600;">{{ item.bill_code }}</text>
            </navigator>
        </view>
        <view style="height: 50%;" class="item">
            <text style="font-weight:bold; font-size: 18px;">申请日期:</text>
            <text style="font-size: 15px;">{{ item.apply_date }}</text>
        </view>
    </view>
    <!-- 单据状态 -->
    <view class="item flex" style=" align-items: center; justify-content: center; float: right; width: 30%; height: 100%;">
        <text style="font-weight:bold; font-size: 18px;">{{ item.approve_state }}</text>
    </view>
</view>

具体如下:

<navigator url="./ApplyDetails?bill_code={{item.pk_hi_stapply}}" hover-class="navigator-hover" >
    <text style="font-size: 15px; font-weight:600;">{{ item.bill_code }}</text>
</navigator>

写法上跟官网给的写法一致,可是编译器会报错,但是程序依旧可以正常编译出来。

错误如下:

16:29:04.096 Module Error (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):
16:29:04.097 (Emitted value instead of an instance of Error) 
16:29:04.102   Errors compiling template:
16:29:04.103   url="./ApplyDetails?bill_code={{item.bill_code}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">.
16:29:04.117   115|  					<view style="height: 50%;" class="item">
16:29:04.125   116|  						<text style="font-weight:bold; font-size: 18px;">申请单编号:</text>
16:29:04.126   117|  						<navigator url="./ApplyDetails?bill_code={{item.bill_code}}" hover-class="navigator-hover" >
16:29:04.134      |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16:29:04.136   118|  						<text style="font-size: 15px; font-weight:600;">{{ item.bill_code }}</text>
16:29:04.158   119|  						</navigator>
16:29:04.162  at E:\SOS\SOS.BGAPP\pages\DHR\DimissionApply.vue:0

为了不让编译器报错,写法可以如下;

<navigator :url="'./ApplyDetails?bill_code={{item.pk_hi_stapply}}'" hover-class="navigator-hover" >
    <text style="font-size: 15px; font-weight:600;">{{ item.bill_code }}</text>
</navigator>

标签:hover,16,app,29,跳转,uni,type
From: https://www.cnblogs.com/wzx-blog/p/16652069.html

相关文章

  • 完全解析Array.apply(null, { length: 1000 })
    Array.apply(null,{length:1000})点击打开视频讲解更加详细在阅读VueJS教程时有这么段democode:render:function(createElement){returncreateElement('div'......
  • CF1513 E Cost Equilibrium / F Swapping Problem
    E先做差,发现排列如果出现正负正负或负正负正就会挂,调整一下匹配即可使min变大同时如果正和负都>1,则不存在中间一段左右两段其他的,这样也会挂然后随便组合一下F手玩发......
  • mybatis-plus-generator 配置不生成 entity, controller, mapper 等
    3.5.2版本有需求不生成controller于是baidu发现如下方法.templateConfig(builder->builder.controller(""))配置后确实不生成controller 又有需求不生成entit......
  • 【基础整理】Mapping representation 机器人所用地图种类及相关介绍
    参考与前言本文主要介绍建图Mapping方面的一些基础知识介绍与相关下游任务使用涉及知识较为基础,SLAM大佬们可以提前退出了主要针对应用为移动机器人与物流无人驾驶......
  • Vue的列表超链接(A标签)是什么?如何实现跳转呢?
    方法一:通过<router-link:to="">我要跳转,别拦我</router-link>首页列表:在这里我用a标签进行跳转,在vue里面使用<router-link></router-link>  //注意:这里的router-lin......
  • unityshader_01
    第一章渲染流水线1.1渲染流水线1.1.1现实中流水线在工业上,流水线被广泛应用在装配线上。假设,老王有一个生产洋娃娃的工厂,一个洋娃娃的生产流程可以分为4个步骤:在流水线......
  • tkMapper
    一、DAO层的实现的规律实体类与数据表存在对应关系,并且是有规律的——只要知道了数据表的结构,就能够生成实体类;所有实体的DAO接口中定义的方法也是有规律的,不同点就......
  • unity prefab的新用法
    预制件是一个可重用的构建块,你可以把各种类型的对象统一成预制件。蓝色立方体是预制件,灰色的是游戏对象。用浏览器自带的翻译软件看的,可能会有一些细节问题......嵌套的......
  • uniapp小程序分包记录
    用uniapp开发微信小程序,发布大小尚若超出2M,那么就无法提交体验版上线,项目完犊子了当然,大小如果超2M,常见的做法一般是把本地图片转移网络图片,或者压缩代码,但如果这些都做过......
  • 如何将Unity3D的工程文件安装到quest中
    本文用于学习笔记,参考链接  作者:倥偬盎离https://www.bilibili.com/read/cv12205073/出处:bilibili一、需要提前安装的软件1.oculus手机应用下载 使用手册上面提供......