用了vant UI的tabBar
// custom-tab-bar/index.js
Component({
data: {
active: 0,
list: [
{
"pagePath": "pages/index/index",
"text": "订单"
},{
"pagePath": "pages/manages/manages",
"text": "管理"
}
],
},
methods: {
// 点击导航栏
onTabBarChange: function(e) {
console.log(e.detail)
let index = e.detail
console.log(this.data.list[index].pagePath)
wx.switchTab({
url: this.data.list[index].pagePath,
})
this.setData({
active: index
})
console.log(this.data.active)
},
}
})
tabBar上点击之后报错
那个"pages/index/pages/manages/manages"是什么鬼啊?页面结构是这样的
为什么switchTab里会自动在前边拼接上pages/index呢?
list: [ { "pagePath": "/pages/index/index", "text": "订单" },{ "pagePath": "/pages/manages/manages", "text": "管理" } ]
请问解决了吗,我也遇到同样的问题了
switchTab只能跳转到带有tab的页面
"tabBar": { "color": "#333", "selectedColor": "#e60027", "borderStyle": "black", "backgroundColor": "white", // "iconWidth":"22rpx", // 设置图标宽度 "list": [{ "pagePath": "pages/tabBar/index/index", "iconPath": "static/tabIcon/tab1.png", "selectedIconPath": "static/tabIcon/tab1choose.png", "text": "首页" }, { "pagePath": "pages/tabBar/center/center", "iconPath": "static/tabIcon/tab2.png", "selectedIconPath": "static/tabIcon/tab2choose.png", "text": "" }, { "pagePath": "pages/tabBar/mine/mine", "iconPath": "static/tabIcon/tab4.png", "selectedIconPath": "static/tabIcon/tab4choose.png", "text": "我的" } ] }
请移步这里https://vant-contrib.gitee.io/vant-weapp/#/tabbar