简体中文
组件类型:UniNavigatorElement
页面链接
Android | iOS | web |
---|---|---|
3.9 | 4.11 | 4.0 |
名称 | 类型 | 默认值 | 描述 | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
target | string | - | 在哪个目标上发生跳转,默认当前应用 | ||||||||||||||||||||||||||||||||||||||
url | string(string.PageURIString) | - | 当前应用内的跳转链接 | ||||||||||||||||||||||||||||||||||||||
open-type | string | "navigate" | 跳转方式 | ||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
delta | number | - | 当 open-type 为 navigateBack 时有效,表示回退的层数 | ||||||||||||||||||||||||||||||||||||||
app-id | string | - | 当target="miniProgram"时有效,要打开的小程序 appId | ||||||||||||||||||||||||||||||||||||||
path | string | - | 当target="miniProgram"时有效,打开的页面路径,如果为空则打开首页 | ||||||||||||||||||||||||||||||||||||||
extra-data | object | - | 当target="miniProgram"时有效,需要传递给目标应用的数据,目标应用可在 App.onLaunch(),App.onShow() 中获取到这份数据 | ||||||||||||||||||||||||||||||||||||||
version | string | - | 当target="miniProgram"时有效,要打开的小程序版本,有效值 develop(开发版),trial(体验版),release(正式版),仅在当前小程序为开发版或体验版时此参数有效;如果当前小程序是体验版或正式版,则打开的小程序必定是正式版 | ||||||||||||||||||||||||||||||||||||||
animation-type | string | "pop-in/out" | 当 open-type="navigateTo" 或 open-type="navigateBack" 时有效,窗口的显示/关闭的动画类型。 | ||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
animation-duration | number | 300 | 当 open-type="navigateTo" 或 open-type="navigateBack" 时有效,窗口的显示/关闭动画的持续时间。 | ||||||||||||||||||||||||||||||||||||||
hover-class | string | - | 指定按下去的样式类。当 hover-class="none" 时,没有点击态效果 | ||||||||||||||||||||||||||||||||||||||
hover-stop-propagation | boolean | - | 指定是否阻止本节点的祖先节点出现点击态 | ||||||||||||||||||||||||||||||||||||||
hover-start-time | number | - | 按住后多久出现点击态,单位毫秒 | ||||||||||||||||||||||||||||||||||||||
hover-stay-time | number | - | 手指松开后点击态保留时间,单位毫秒 | ||||||||||||||||||||||||||||||||||||||
render-link | boolean | true | 是否给 navigator 组件加一层 a 标签控制 ssr 渲染 |
Android | iOS | web | |
---|---|---|---|
navigate | 3.9 | 4.11 | 4.0 |
redirect | 3.9 | 4.11 | 4.0 |
switchTab | 3.9 | 4.11 | 4.0 |
reLaunch | 3.9 | 4.11 | 4.0 |
navigateBack | 3.9 | 4.11 | 4.0 |
Android | iOS | web | |
---|---|---|---|
target | 3.9 | 4.11 | 4.0 |
url | 3.9 | 4.11 | 4.0 |
open-type | 3.9 | 4.11 | 4.0 |
delta | 3.9 | 4.11 | 4.0 |
path | 3.9 | x | 4.0 |
animation-type | 3.9 | 4.11 | 4.0 |
animation-duration | 3.9 | 4.11 | 4.0 |
render-link | x | x | 4.0 |
Template
Script
<template>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<navigator class="navigator navigate" url="navigate?title=navigate">
<button type="default">跳转到新页面</button>
</navigator>
<navigator class="navigator redirect" url="redirect?title=redirect" open-type="redirect">
<button type="default">在当前页打开</button>
</navigator>
<navigator style="flex-direction: row;justify-content: space-between;">
<text>两端对齐样式测试</text>
<view style="width: 20px;height: 20px; background-color: aqua;"></view>
</navigator>
</view>
</template>
<style>
.navigator {
margin-bottom: 15px;
}
</style>
navigator组件是对uni.navigateTo API的易用性封装,无需编写method方法,直接跳转页面。跳转后的新页面在onload生命周期中接收参数,详见页面onLoad生命周期