navigateTo
tip
保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 navigateBack 可以返回到原页面。
参数说明
| 属性 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
type | string | 是 | 可选值 native (原生页面) 或 local_webview (离线页面) 或 webview (在线网页) |
key | string | 否 | 当 type 为 native 或 local_webview 时必填 key |
url | string | 否 | 当 type 为 webview 时必填 url |
popOthers | boolean | 否 | 跳转到新页面之后 保留当前页面并关闭所有非tabbar的页面 |
initData | string | 否 | 有传值时需要将此对象注入到 webview 中的 window._initData 对象上 |
statusBarStyle | string | dark | 状态栏字体颜色 黑色: dark 白色: light |
hideNavigation | boolean | 否 | 当 type 为 webview 或 local_webview 时可选填 hideNavigation |
query | Object | 否 | { slug: "privacy-policy" } |
success | function | 否 | 接口调用成功的回调函数 |
fail | function | 否 | 接口调用失败的回调函数 |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
1.跳转到离线webview页面
a. 不带参数跳转
dsBridge.call(
'navigateTo',
{
type: 'local_webview', // 离线webview页面
hideNavigation: true, // 隐藏顶部导航栏
statusBarStyle: 'dark', // 状态栏字体颜色(黑色|白色) 'dark' | 'light'
initData: "{\"id\":\"226f161d-3810-4f85-9dee-fcc8438a1b57\",\"name\":\"广州市花都区狮岭谷田丰皮革商行\",\"brand_name\":\"田丰皮革商行\",\"logo_url\":\"https://files-dev.for1688.cn/cbu01/ibank/O1CN01vnmNmK2LTu9EwfHQ8_!!2211586579694-0-cib.jpg\"}", // 需要注入到window对象上的全局变量
key: 'render_catalogue', // 离线页面key
}
)
不带参数离线地址示例
https://render-dev.for1688.cn/catalogue/
b. 带参数跳转
dsBridge.call(
'navigateTo',
{
type: 'local_webview', // 离线webview页面
hideNavigation: true, // 隐藏导航栏
initData: "{\"id\":\"226f161d-3810-4f85-9dee-fcc8438a1b57\",\"name\":\"广州市花都区狮岭谷田丰皮革商行\",\"brand_name\":\"田丰皮革商行\",\"logo_url\":\"https://files-dev.for1688.cn/cbu01/ibank/O1CN01vnmNmK2LTu9EwfHQ8_!!2211586579694-0-cib.jpg\"}", // 需要注入到window对象上的全局变量
key: 'render_page', // 离线页面key
query: {
slug: 'privacy-policy'
}
}
)
带参数离线地址示例
https://render-dev.for1688.cn/page/?slug=privacy-policy
离线页面配置示例
{
"pages": [
{
"title": "聚鞋优品",
"key": "render_home", //页面入口唯一id, 通过key打开离线webview页面的方法需要用到
"project": "render",
"url": "https://render-dev.for1688.cn/", // 通过判断url是否包含离线包中的rootUrl来确定是否离线包
"querys": [],
"hideNavigation": true, // 是否隐藏标题栏
"disableBounce": true, // 是否禁用橡皮筋效果(iOS)
"updatedAt": 1628437177827
},
{
"title": "商品目录",
"key": "render_catalogue",
"project": "render",
"url": "https://render-dev.for1688.cn/catalogue/", // 通过判断url是否包含离线包中的rootUrl来确定是否离线包
"querys": [],
"hideNavigation": true,
"disableBounce": true,
"updatedAt": 1628437177827
},
{
"title": "自定义页面",
"key": "render_page",
"project": "render",
"url": "https://render-dev.for1688.cn/page/", // 通过判断url是否包含离线包中的rootUrl来确定是否离线包
"querys": ["slug"],
"hideNavigation": false,
"disableBounce": true,
"updatedAt": 1628437177827
},
]
}
2.跳转到原生页面
跳转到非 tabBar 页面
dsBridge.call(
'navigateTo',
{
type: 'native', // app 原生页面
key: 'yideapp://login/loginView', // ios 登录页面
}
)
yideapp://login/loginView -----登录
yideapp://login/accountLoginView -----账号密码登录
yideapp://login/findPwd -----找回密码
yideapp://session/friendList -----好友列表
yideapp://session/friendDetail -----好友详情
yideapp://session/sessionList -----最近会话列表
yideapp://session/session -----发起会话
3.跳转到在线web页面
dsBridge.call(
'navigateTo',
{
type: 'webview' // app 原生页面
url: 'https://www.for1688.cn/', // url 地址
}
)