页面跳转优先采用navigator组件。 小程序提供了两种页面路由方式: a. navigator 组件 b. 路由 API,包括 navigateTo / redirectTo / switchTab / navigateBack / reLaunch 建议使用 navigator 组件,若不得不使用API,可在爬虫访问时屏蔽针对点击设置的时间锁或变量锁。
上面是引入微信官方关于页面跳转的使用建议 小程序默认是不能跳转到tabber页面的,这点在首次使用navigator来跳转tabbar页且不熟悉文档可能会懵逼,以为是自己哪里写错。 根据以上说明,要跳转到tabbar页的设置方式有两种:
wxml:
<navigator url="/pages/index/index" open-type='switchTab'>首页</navigator>
或者js:
wx
.switchTab({
url
: "/pages/index/index"
})