https://developers.weixin.qq.com/miniprogram/dev/extended/weui/tabbar.html 这个扩展的tabbar怎么像app.json全局定义的tabbar一样切换页面,使用
wx.switchTab 提示 switchTab:fail can not switch to no-tabBar page
import CustomPage from '../../weui/base/CustomPage'
const app = getApp()
CustomPage({
onShareAppMessage() {
return {
title: 'tabbar',
path: 'page/home/home'
}
},
data: {
current: 0,
list: [{
text: '通讯录',
badge: '8',
pagePath: 'AddressBook/AddressBook'
},
{
text: '通话记录',
dot: true,
pagePath: 'CallRecords/CallRecords'
}
]
},
tabChange(e) {
var index = e.detail.index
var item = e.detail.item
var path = item.pagePath
const data = e.currentTarget.dataset;
console.log("tabBar参数:", data);
console.log(path)
wx.switchTab({
url: path,
complete: (res) => {console.log(res)},
fail: (res) => {console.log(res)},
success: (res) => {console.log(res)},
})
console.log('tab change', index)
console.log('tab change', e)
}
});
扩展的tabBar没在app.json里,所以你不能使用switchTab