mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 18:54:24 +00:00
[new feature] Tabbar: add route prop
This commit is contained in:
@@ -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 (
|
||||
|
Reference in New Issue
Block a user