init: initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const { tabForPage, paths } = require('../../utils/navigation');
|
||||
Component({
|
||||
data: { active: '' },
|
||||
lifetimes: { attached: function() { this.syncActive(); } },
|
||||
pageLifetimes: { show: function() { this.syncActive(); } },
|
||||
methods: {
|
||||
syncActive: function() {
|
||||
var pages = getCurrentPages();
|
||||
var current = pages[pages.length - 1];
|
||||
this.setData({ active: tabForPage(current && current.route) });
|
||||
},
|
||||
navigate: function(e) {
|
||||
var tab = e.currentTarget.dataset.tab;
|
||||
if (!paths[tab]) return;
|
||||
var pages = getCurrentPages();
|
||||
// 当前主页面重复点击不重新加载。
|
||||
if (pages.length && pages[pages.length - 1].route === paths[tab]) return;
|
||||
wx.reLaunch({ url: '/' + paths[tab] });
|
||||
}
|
||||
} });
|
||||
Reference in New Issue
Block a user