[new feature] Tabbar: add route prop

This commit is contained in:
陈嘉涵
2019-05-13 14:48:55 +08:00
parent f94df82ceb
commit 96b1d8f81d
7 changed files with 284 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import { use } from '../utils';
import { use, isObj } from '../utils';
import Icon from '../icon';
import Info from '../info';
import { route, routeProps } from '../utils/router';
@@ -22,6 +22,16 @@ export default sfc({
};
},
computed: {
routeActive() {
const { to, $route } = this;
if (to && $route) {
const path = isObj(to) ? to.path : to;
return $route.path === path;
}
}
},
methods: {
onClick(event) {
this.parent.onChange(this.index);
@@ -31,7 +41,8 @@ export default sfc({
},
render(h) {
const { icon, slots, active } = this;
const { icon, slots } = this;
const active = this.parent.route ? this.routeActive : this.active;
const color = this.parent[active ? 'activeColor' : 'inactiveColor'];
return (