tt.switchTab
收藏我的收藏
基础库 1.0.0 开始支持本方法,这是一个异步方法。
跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面,目标 tabBar 页面需要在 app.json 中定义。
语法
tt.switchTab(options)
参数说明
options 为 object 类型,属性如下:
属性名  | 类型  | 默认值  | 必填  | 说明  | 最低支持版本  | 
|---|---|---|---|---|---|
url  | string  | 是  | 目标 tabBar 页面的路径(在 app.json 的 tabBar 字段中定义的页面),路径后不能带参数  | 1.0.0  | |
success  | function  | 否  | 接口调用成功的回调函数  | 1.0.0  | |
fail  | function  | 否  | 接口调用失败的回调函数  | 1.0.0  | |
complete  | function  | 否  | 接口调用结束的回调函数(调用成功、失败都会执行)  | 1.0.0  | 
回调成功
object 类型,属性如下:
属性名  | 类型  | 说明  | 最低支持版本  | 
|---|---|---|---|
errMsg  | string  | "switchTab:ok"  | 1.0.0  | 
回调失败
object 类型,属性如下:
属性名  | 类型  | 说明  | 最低支持版本  | 
|---|---|---|---|
errMsg  | string  | "switchTab:fail " + 错误信息  | 1.0.0  | 
错误说明
errNo  | errMsg  | 说明  | 最低支持版本  | 
|---|---|---|---|
20000  | switchTab:fail params.url should be string, but got undefined  | url 未传  | 2.28.0  | 
20000  | switchTab:fail params.url should be string, but got ${url}  | url 为非字符串  | 2.28.0  | 
20000  | switchTab:fail url is invalid  | url 无效  | 2.28.0  | 
21301  | switchTab:fail top view is null  | 当前未打开任何页面  | 2.28.0  | 
21102  | switchTab:fail The target page is not tab  | 目标页面不是一个 tabBar 页面  | 2.28.0  | 
21200  | switchTab:fail Full screen player exists  | 全屏播放器状态下不允许跳转  | 2.28.0  | 
21500  | switchTab:fail illegal content found  | 未通过敏感词检测  | 2.28.0  | 
21500  | switchTab:fail url "${removeHtmlSuffixFromUrl(url)}" is not in app.json  | 页面未在 app.json 中配置  | 2.28.0  | 
21500  | switchTab:fail this page has been blocked  | 目标页面被屏蔽  | 2.28.0  | 
扫码体验
代码示例
Bug & Tip
- Tip: 使用 navigator 组件也可以实现同样的功能。
 
