界面交互 API
| 名称 | 功能说明 |
|---|---|
| wx.showModal | 显示模态对话框 |
| wx.showToast | 显示消息提示框 |
| wx.hideToast | 隐藏消息提示框 |
| wx.showLoading | 显示 loading 提示框 |
| wx.hideLoading | 隐藏 loading 提示框 |
小程序页面跳转
小程序跳转页面主要有两种方式:
<navigator>组件直接跳转。- 事件绑定内部通过
WX API跳转。
路由 API
WX API | 备注 | 官方功能说明 |
|---|---|---|
| wx.switchTab | 跳转 tabBar 页 | 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面 |
| wx.reLaunch | 重启整个小程序 | 关闭所有页面,打开到应用内的某个页面 |
| wx.redirectTo | 替换页面 | 关闭当前页面,跳转到应用内的某个页面 |
| wx.navigateTo | 跳转普通页 | 保留当前页面,跳转到应用内的某个页面 |
| wx.navigateBack | 普通页的后退 | 关闭当前页面,返回上一页面或多级页面 |
<navigator> 组件写法
<navigator open-type="navigate">跳转普通页</navigator>
<navigator open-type="redirect">替换普通页</navigator>
<navigator open-type="switchTab">跳转tabBar页</navigator>
<navigator open-type="reLaunch">重启小程序</navigator>
<navigator open-type="navigateBack">后退返回</navigator>
| open-type 的合法值 | 说明 |
|---|---|
| navigate | 对应 wx.navigateTo 的功能 |
| redirect | 对应 wx.redirectTo 的功能 |
| switchTab | 对应 wx.switchTab 的功能 |
| reLaunch | 对应 wx.reLaunch 的功能 |
| navigateBack | 对应 wx.navigateBack 的功能 |