You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

Component({
data: {
selected: null, //当前选中的tab下标
color: "#1E1E1E",
selectedColor: "#646464", //tabbar选中字体颜色
list: [{
"pagePath": "pages/index/index",
"iconPath": "icons/home.png",
"selectedIconPath": "icons/homeActive.png",
"text": "首页"
},
{
"pagePath": "pages/insight/index",
"iconPath": "icons/insight.png",
"selectedIconPath": "icons/insightActive.png",
"text": "洞察"
},
{
"pagePath": "pages/brandSearch/index",
"iconPath": "icons/appSearch.png",
"selectedIconPath": "icons/appSearchActive.png",
"text": "品牌搜索"
},
{
"pagePath": "pages/varComm/index",
"iconPath": "icons/varComm.png",
"selectedIconPath": "icons/varCommActive.png",
"text": "对比"
},
{
"pagePath": "pages/mine/index",
"iconPath": "icons/mine.png",
"selectedIconPath": "icons/mineActive.png",
"text": "我的"
}
], //tabbar循环数据集
},
attached() {},
methods: {
switchTab(e) {
const data = e.currentTarget.dataset;
const url = data.path
// this.setData({
// selected: data.index
// })
wx.switchTab({
url: "/" + url
})
},
init() {
const page = getCurrentPages().pop();
let n = this.data.list.findIndex(item => item.pagePath === `${page.route}`);
this.setData({
selected: n
});
}
},
})