// compontents/tarbar/tarbar.js const util = require('../../utils/util.js'); Component({ /** * 组件的属性列表 * 第一次进入课程的nav */ properties: { }, /** * 组件的初始数据 */ data: { motto: ['我的','错题本','语文','数学','中文','英语','科学','艺术'], navBtnSelectIdx: 0, left: 0 }, /** * 组件的方法列表 */ methods: { navItemTap: function (e) { //更改navBtnSelectIdx加class let index = e.target.dataset.index; if (index != this.navBtnSelectIdx) { this.setData({ navBtnSelectIdx: index}); } //移动nav if (index <= 2) { this.setData({ left: 0 }); } if(index > 2){ this.setData({left: 200 }); } if(index == 0) { wx.redirectTo({ url: '../index/index?ind=0' }) } if(index == 1) { wx.redirectTo({ url: '../mistakes/mistakes?ind=1' }) } if(index == 2) { wx.redirectTo({ url: '../language/language?ind=2' }) } if(index == 3) { wx.redirectTo({ url: '../mathematics/mathematics?ind=3' }) } if(index == 4) { wx.redirectTo({ url: '../chinese/chinese?ind=4' }) } if(index == 5) { wx.redirectTo({ url: '../english/english?ind=5' }) } if(index == 6) { wx.redirectTo({ url: '../science/science?ind=6' }) } if(index == 7) { wx.redirectTo({ url: '../art/art?ind=7' }) } } }, ready() { let options = util.getUrl(); const ind = options.ind || util.convertObject(unescape(options.scene)).ind; if(ind) { this.setData({ navBtnSelectIdx: ind}); } if (ind <= 2) { this.setData({ left: 0 }); } if(ind > 2){ this.setData({left: 200 }); } } })