微信小程序 坑 navigator 不跳转不报错
在做微信小程序页面中 使用navigator 实现跳转时出现 没反应 不跳转 不报错
1.0 navigator
页面链接 跳转 类似于a标签
2.0 解决方法:open-type
在文档中有这一个属性 open-type 跳转方式 一共有6个 :
navigate:保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabBar 页面。使用 wx.navigateBack 可以返回到原页面。
redirect:关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabBar 页面。
switchTab:跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
reLaunch:关闭所有页面,打开到应用内的某个页面
navigateBack:关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages() 获取当前的页面栈,决定需要返回几层。
exit:退出小程序,target="miniProgram" 时生效
需要注意的是:switchTab只能跳转到 tabBar 页面!!!
不在这 tabBar 链接内的继续使用open-type="switchTab"是无法跳转的!
别问我是怎么知道的,因为我掉坑里了!
3.0 wx.navigateTo 跳转的页面为在app.json里面注册过的tabBar页面,无法跳转
解决方法:
在app.json里面注册过的tabBar的页面要使用wx.switchTab才能进行跳转。
wx.navigateTo跳转的页面层级太多导致无法跳转 微信小程序规定子页面最多跳转5层。
wx.switchTab{(
url:'page/index/index'
})

浙公网安备 33010602011771号