
简体中文
保留当前页面,跳转到应用内的某个页面
Web | 微信小程序 | Android | iOS | HarmonyOS |
---|---|---|---|---|
4.0 | 4.41 | √ | 4.11 | 4.61 |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | NavigateToOptions | 是 | - | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | - |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errCode | number | 是 | - | - | 路由错误码 - 4: 框架内部异常 |
errSubject | string | 是 | - | - | 统一错误主题(模块)名称 |
data | any | 否 | - | - | 错误信息中包含的数据 |
cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | - |
类型 | 必备 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Promise<AsyncApiSuccessResult> | 否 | ||||||||||||
|
关闭当前页面,跳转到应用内的某个页面
Web | 微信小程序 | Android | iOS | HarmonyOS |
---|---|---|---|---|
4.0 | 4.41 | √ | 4.11 | 4.61 |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | RedirectToOptions | 是 | - | - | |||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errCode | number | 是 | - | - | 路由错误码 - 4: 框架内部异常 |
errSubject | string | 是 | - | - | 统一错误主题(模块)名称 |
data | any | 否 | - | - | 错误信息中包含的数据 |
cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | - |
类型 | 必备 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Promise<AsyncApiSuccessResult> | 否 | ||||||||||||
|
关闭所有页面,打开到应用内的某个页面
Web | 微信小程序 | Android | iOS | HarmonyOS |
---|---|---|---|---|
4.0 | 4.41 | √ | 4.11 | 4.61 |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | ReLaunchOptions | 是 | - | - | |||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errCode | number | 是 | - | - | 路由错误码 - 4: 框架内部异常 |
errSubject | string | 是 | - | - | 统一错误主题(模块)名称 |
data | any | 否 | - | - | 错误信息中包含的数据 |
cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | - |
类型 | 必备 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Promise<AsyncApiSuccessResult> | 否 | ||||||||||||
|
跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
Web | 微信小程序 | Android | iOS | HarmonyOS |
---|---|---|---|---|
4.0 | 4.41 | √ | 4.11 | 4.61 |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | SwitchTabOptions | 是 | - | - | |||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errCode | number | 是 | - | - | 路由错误码 - 4: 框架内部异常 |
errSubject | string | 是 | - | - | 统一错误主题(模块)名称 |
data | any | 否 | - | - | 错误信息中包含的数据 |
cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | - |
类型 | 必备 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Promise<AsyncApiSuccessResult> | 否 | ||||||||||||
|
关闭当前页面,返回上一页面或多级页面
Web | 微信小程序 | Android | iOS | HarmonyOS |
---|---|---|---|---|
4.0 | 4.41 | √ | 4.11 | 4.61 |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | NavigateBackOptions | 否 | - | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errCode | number | 是 | - | - | 路由错误码 - 4: 框架内部异常 |
errSubject | string | 是 | - | - | 统一错误主题(模块)名称 |
data | any | 否 | - | - | 错误信息中包含的数据 |
cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | - |
类型 | 必备 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Promise<AsyncApiSuccessResult> | 否 | ||||||||||||
|
Template
Script
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head title="navigate"></page-head>
<view style="flex-direction: row;">
<switch @change="onChange"></switch>
<view class="uni-title">是否启用共享元素动画</view>
</view>
<share-element :share-key="shareElementKey">
<image style="width: 250px; height: 176px;" src="/static/shuijiao.jpg" mode="scaleToFill"></image>
</share-element>
<text style="font-size: 13px;" >注意:开启共享元素动画后仅支持slide-in-right和fade-in动画效果</text>
<view class="uni-padding-wrap uni-common-mt uni-common-mb">
<view class="direction-row">
<text class="label">onLoad触发时间戳:</text>
<text>{{ onLoadTime }}</text>
</view>
<view class="direction-row">
<text class="label">onShow触发时间戳:</text>
<text>{{ onShowTime }}</text>
</view>
<view class="direction-row">
<text class="label">onReady触发时间戳:</text>
<text>{{ onReadyTime }}</text>
</view>
<view class="direction-row">
<text class="label">onHide触发时间戳:</text>
<text>{{ onHideTime }}</text>
</view>
<view class="direction-row">
<text class="label">onBackPress触发时间戳:</text>
<text>见控制台</text>
</view>
<view class="direction-row">
<text class="label">onUnload触发时间戳:</text>
<text>见控制台</text>
</view>
<view class="uni-btn-v">
<button @tap="navigateTo" class="uni-btn">
跳转新页面,并传递数据
</button>
<button @tap="navigateBack" class="uni-btn">返回上一页</button>
<button @tap="redirectTo" class="uni-btn">在当前页面打开</button>
<button @tap="switchTab" class="uni-btn">切换到模板选项卡</button>
<button @tap="reLaunch" class="uni-btn">
关闭所有页面,打开首页
</button>
<button @tap="navigateToErrorPage" class="uni-btn">
打开不存在的页面
</button>
<button v-for="(item, _) in animationTypeList" @tap="navigateToAnimationType(item)"
class="uni-btn">navigateTo动画({{item}})</button>
<button class="uni-btn" @click="goOnLoadCallAPI">测试 onLoad 调用 API</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<style>
.direction-row {
flex-direction: row;
}
.label {
width: 190px;
}
</style>
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | 错误信息 |
A页面跳转到B页面时,有两种方式给B页面传递信息:
navigateTo
, redirectTo
只能打开非 tabBar 页面。switchTab
只能打开 tabBar
页面。reLaunch
可以打开任意页面。tabBar
由页面决定,即只要是定义为 tabBar
的页面,底部都有 tabBar
。onReady
之前进行页面跳转。