// custom-tab-bar/index.js let app = getApp(); Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { selectIndex: 0, tabbar: app.globalData.tabbar || { custom: true, color: "#000000", selectedColor: "#004445", backgroundColor: "#ffffff", position: "bottom", borderStyle: "white", list: [{ "pagePath": "/pages/index/index", "text": "首页", iconfont: 'icon-shouye', show: true }, { "pagePath": "/pages/shenhe/shenhe", "text": "审核", iconfont: 'icon-shenhe', show: false }, { "pagePath": "/pages/cart/cart", "text": "购物袋", iconfont: 'icon-gouwudai2', show: true }, { "pagePath": "/pages/user/index/index", "text": "我的", iconfont: 'icon-wode', show: true } ] } }, observers: { selectIndex: function (selectIndex) { //console.log(selectIndex); } }, onReady() { //console.log(111) }, onShow() { //console.log("tabbar...") }, /** * 组件的方法列表 */ methods: { goBar(e) { //console.log(e.currentTarget.dataset); let item = e.currentTarget.dataset.item; // this.setData({ // selectIndex: e.currentTarget.dataset.index // }); //console.log(this.data.selectIndex) wx.switchTab({ url: item.pagePath, fail(e) { //console.log(e) } }) } } })