diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index c15a6a4..296a652 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -1,52 +1,51 @@ - Component({ data: { - selected: 0,//当前选中的tab下标 - color: "#1E1E1E", - selectedColor: "#646464",//tabbar选中字体颜色 - list: [{ - "pagePath": "pages/index/index", - "iconPath": "/components/tabbarComponent/icons/home.png", - "selectedIconPath": "icons/homeActive.png", - "text": "首页" - }, - { - "pagePath": "pages/insight/index", - "iconPath": "/components/tabbarComponent/icons/insight.png", - "selectedIconPath": "icons/insightActive.png", - "text": "洞察" - }, - { - "pagePath": "pages/brandSearch/index", - "iconPath": "/components/tabbarComponent/icons/appSearch.png", - "selectedIconPath": "icons/appSearchActive.png", - "text": "品牌搜索" - }, - { - "pagePath": "pages/varComm/index", - "iconPath": "/components/tabbarComponent/icons/varComm.png", - "selectedIconPath": "icons/varCommActive.png", - "text": "对比" - }, - { - "pagePath": "pages/mine/index", - "iconPath": "/components/tabbarComponent/icons/mine.png", - "selectedIconPath": "icons/mineActive.png", - "text": "我的" - } - ],//tabbar循环数据集 - }, - attached() { + selected: 0, //当前选中的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}) - } + switchTab(e) { + const data = e.currentTarget.dataset; + const url = data.path + this.setData({ + selected: data.index + }) + wx.switchTab({ + url + }) + } }, - }) - \ No newline at end of file +}) \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index 9b69b29..6540b4d 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -49,7 +49,7 @@ Page({ }, onLoad: function (options) { - app.editTabbar() + }, })