mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Tabbar): support highlighted with child route (#9926)
This commit is contained in:
parent
3b6f14e57b
commit
3ed8fae93b
@ -57,10 +57,11 @@ export default defineComponent({
|
|||||||
const { $route } = vm;
|
const { $route } = vm;
|
||||||
const { to } = props;
|
const { to } = props;
|
||||||
const config = isObject(to) ? to : { path: to };
|
const config = isObject(to) ? to : { path: to };
|
||||||
const pathMatched = 'path' in config && config.path === $route.path;
|
return !!$route.matched.find((val) => {
|
||||||
const nameMatched = 'name' in config && config.name === $route.name;
|
const pathMatched = 'path' in config && config.path === val.path;
|
||||||
|
const nameMatched = 'name' in config && config.name === val.name;
|
||||||
return pathMatched || nameMatched;
|
return pathMatched || nameMatched;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (props.name ?? index.value) === modelValue;
|
return (props.name ?? index.value) === modelValue;
|
||||||
|
@ -10,6 +10,7 @@ function getMockRouter() {
|
|||||||
const $route = reactive({
|
const $route = reactive({
|
||||||
name: '/',
|
name: '/',
|
||||||
path: '/',
|
path: '/',
|
||||||
|
matched: [{ name: '/', path: '/' }],
|
||||||
});
|
});
|
||||||
const push = (val: unknown) => {
|
const push = (val: unknown) => {
|
||||||
if (typeof val === 'string') {
|
if (typeof val === 'string') {
|
||||||
@ -18,6 +19,7 @@ function getMockRouter() {
|
|||||||
} else {
|
} else {
|
||||||
Object.assign($route, val);
|
Object.assign($route, val);
|
||||||
}
|
}
|
||||||
|
$route.matched = [{ name: $route.name, path: $route.path }];
|
||||||
};
|
};
|
||||||
const $router = {
|
const $router = {
|
||||||
push,
|
push,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user