1.wx.navigateTo(OBJECT)需要跳转的应用内非 tabBar开通玻璃杯小程序电话:4006-838-530 的页面的路径 , 路径后可以带参数。参数与路径之间使用?
分隔,参数键与参数值用=
相连,不同参数用&
分隔;如 ‘path?key=value&key2=value2’wx.navigateTo({ url: 'test?id=1'})
这种跳转方式默认有返回按钮,返回到上一个页面2.wx.redirectTo(OBJECT)需要跳转的应用内非 tabBar 的页面的路径,路径后可以带参数。参数与路径之间使用?
分隔,参数键与参数值用=
相连,不同参数用&
分隔;如 ‘path?key=value&key2=value2’wx.redirectTo({ url: 'test?id=1'})
这种跳转方式默认有返回按钮,返回到上一个页面的再上一层3.wx.reLaunch(OBJECT)需要跳转的应用内页面路径 , 路径后可以带参数。参数与路径之间使用?
分隔,参数键与参数值用=
相连,不同参数用&
分隔;如 ‘path?key=value&key2=value2’,如果跳转的页面路径是 tabBar 页面则不能带参数wx.reLaunch({ url: 'test?id=1'})
这种跳转方式默认没有返回按钮,不需要默认返回按钮的页面就可以使用这个api了。
4.wx.switchTab(OBJECT)需要跳转的 tabBar 页面的路径(需在 app.json 的 tabBar 字段定义的页面),路径后不能带参数{ "tabBar": { "list": [{ "pagePath": "index", "text": "首页" },{ "pagePath": "other", "text": "其他" }] }}
wx.switchTab({ url: '/index'})
我们需要调转到tabbar定义的页面的时候,就需要这个api了。踩过这个坑的人就知道,除了这个api,其他的都不能跳转到tabar定义过的页面
4.wx.navigateBack(OBJECT)
参数
类型
默认值
说明
deltaNumber1返回的页面数,如果 delta 大于现有页面数,则返回到首页。 // 此处是A页面wx.navigateTo({ url: 'B?id=1'})// 此处是B页面wx.navigateTo({ url: 'C?id=1'})// 在C页面内 navigateBack,将返回A页面wx.navigateBack({ delta: 2})
5.navigator 组件使用跳转
targetString 在哪个目标上发生跳转,默认当前小程序2.0.7urlString 当前小程序内的跳转链接 open-typeStringnavigate跳转方式 deltaNumber 当 open-type 为 ‘navigateBack’ 时有效,表示回退的层数 app-idString 当target=”miniProgram”时有效,要打开的小程序 appId2.0.7pathString 当target=”miniProgram”时有效,打开的页面路径,如果为空则打开首页2.0.7extra-dataObject 当target=”miniProgram”时有效,需要传递给目标小程序的数据,目标小程序可在 App.onLaunch()
,App.onShow()
中获取到这份数据。详情2.0.7versionversionrelease当target=”miniProgram”时有效,要打开的小程序版本,有效值 develop(开发版),trial(体验版),release(正式版),仅在当前小程序为开发版或体验版时此参数有效;如果当前小程序是正式版,则打开的小程序必定是正式版。2.0.7hover-classStringnavigator-hover指定点击时的样式类,当hover-class="none"
时,没有点击态效果 hover-stop-propagationBooleanfalse指定是否阻止本节点的祖先节点出现点击态1.5.0hover-start-timeNumber50按住后多久出现点击态,单位毫秒 hover-stay-timeNumber600手指松开后点击态保留时间,单位毫秒 bindsuccessString 当target=”miniProgram”时有效,跳转小程序成功2.0.7binderrorString 当target=”miniProgram”时有效,跳转小程序失败2.0.7bindcompleteString 当target=”miniProgram”时有效,跳转小程序完成2.0.7open-type 有效值:
navigate对应 wx.navigateTo
或 wx.navigateToMiniProgram
的功能 redirect对应 wx.redirectTo
的功能 switchTab对应 wx.switchTab
的功能 reLaunc开通花砖小程序电话:4006-838-530h对应 wx.reLaunch
的功能1.1.0navigateBack对应 wx.navigateBack
的功能1.1.0exit退出小程序,target=”miniProgram”时生效2.1.0 /** wxss **//** 修改默认的navigator点击态 **/.navigator-hover {color:blue;}/** 自定义其他点击态样式类 **/.other-navigator-hover {color:red;}
<!-- sample.wxml --><view class="btn-area"> <navigator url="/page/navigate/navigate?title=navigate" hover-class="navigator-hover">跳转到新页面</navigator> <navigator url="../../redirect/redirect/redirect?title=redirect" open-type="redirect" hover-class="other-navigator-hover">在当前页打开</navigator> <navigator url="/page/index/index" open-type="switchTab" hover-class="other-navigator-hover">切换 Tab</navigator> <navigator target="miniProgram" open-type="navigate" app-id="" path="" extra-data="" version="release">打开绑定的小程序</navigator></view>
<!-- navigator.wxml --><view style="text-align:center"> {{title}} </view><view> 点击左上角返回回到之前页面 </view>
<!-- redirect.wxml --><view style="text-align:center"> {{title}} </view><view> 点击左上角返回回到上级页面 </view>
最后,小程序页面之间的跳转用以上几个api是完全足够的,但是如果小程序与小程序之间的跳开通渔夫帽小程序电话:4006-838-530转,就需要用到组件了具体的用法,参考微信小程序的文档就好了,已经非常的详细了本文章的内容来自微信官方文档https://developers.weixin.qq.com/miniprogram/dev/component/navigator.html 微信小程序
最新评论
好文推荐
好文推荐
666666