mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-07-13 01:11:07 +08:00
Compare commits
2 Commits
b8729d8ffb
...
a7081b7e80
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7081b7e80 | ||
|
|
e5ead06d12 |
@ -1,7 +1,7 @@
|
||||
name: 我要反馈 Vant 的 Bug
|
||||
description: 通过标准模板进行 Bug 反馈。
|
||||
title: "[Bug Report] 在此填写标题"
|
||||
labels: ["🐞 bug"]
|
||||
title: "[Bug Report] 请在此填写标题"
|
||||
labels: ["bug: need confirm"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
name: 我要反馈 Vant Cli 的 Bug
|
||||
description: 通过标准模板进行 Bug 反馈。
|
||||
title: "[Bug Report] 在此填写标题"
|
||||
labels: ["🐞 bug", "cli"]
|
||||
title: "[Bug Report] 请在此填写标题"
|
||||
labels: ["bug: need confirm", "cli"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
name: 我想要一个 Vant 的新功能
|
||||
description: 通过标准模板描述一下你的功能需求。
|
||||
title: "[Feature Request] 在此填写标题"
|
||||
labels: ["💡 feature"]
|
||||
title: "[Feature Request] 请在此填写标题"
|
||||
labels: ["feature: need confirm"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
name: 我想要一个 Vant Cli 的新功能
|
||||
description: 通过标准模板描述一下你的功能需求。
|
||||
title: "[Feature Request] 在此填写标题"
|
||||
labels: ["💡 feature", "cli"]
|
||||
title: "[Feature Request] 请在此填写标题"
|
||||
labels: ["feature: need confirm", "cli"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
name: Bug Report
|
||||
description: Use issue template to report a bug.
|
||||
title: "[Bug Report] Title"
|
||||
labels: ["🐞 bug"]
|
||||
labels: ["bug: need confirm"]
|
||||
body:
|
||||
- type: input
|
||||
id: reproduce
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
name: Feature Request
|
||||
description: Use issue template to request a new feature.
|
||||
title: "[Feature Request] Title"
|
||||
labels: ["💡 feature"]
|
||||
labels: ["feature: need confirm"]
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
"dev": "pnpm dev --dir ./packages/vant",
|
||||
"lint": "pnpm lint --dir ./packages/vant",
|
||||
"test": "pnpm test --dir ./packages/vant",
|
||||
"test:watch": "pnpm test:watch --dir ./packages/vant",
|
||||
"build": "pnpm build --dir ./packages/vant",
|
||||
"build:site": "pnpm build:site --dir ./packages/vant"
|
||||
},
|
||||
|
||||
@ -63,13 +63,14 @@ export default defineComponent({
|
||||
return pathMatched || nameMatched;
|
||||
}
|
||||
|
||||
return (props.name || index.value) === modelValue;
|
||||
return (props.name ?? index.value) === modelValue;
|
||||
});
|
||||
|
||||
const onClick = (event: MouseEvent) => {
|
||||
parent.setActive(props.name ?? index.value);
|
||||
if (!active.value) {
|
||||
parent.setActive(props.name ?? index.value, route);
|
||||
}
|
||||
emit('click', event);
|
||||
route();
|
||||
};
|
||||
|
||||
const renderIcon = () => {
|
||||
|
||||
@ -44,7 +44,7 @@ export type TabbarProps = ExtractPropTypes<typeof tabbarProps>;
|
||||
|
||||
export type TabbarProvide = {
|
||||
props: TabbarProps;
|
||||
setActive: (active: number | string) => void;
|
||||
setActive: (active: number | string, afterChange: () => void) => void;
|
||||
};
|
||||
|
||||
export const TABBAR_KEY: InjectionKey<TabbarProvide> = Symbol(name);
|
||||
@ -83,16 +83,15 @@ export default defineComponent({
|
||||
);
|
||||
};
|
||||
|
||||
const setActive = (active: number | string) => {
|
||||
if (active !== props.modelValue) {
|
||||
callInterceptor(props.beforeChange, {
|
||||
args: [active],
|
||||
done() {
|
||||
emit('update:modelValue', active);
|
||||
emit('change', active);
|
||||
},
|
||||
});
|
||||
}
|
||||
const setActive = (active: number | string, afterChange: () => void) => {
|
||||
callInterceptor(props.beforeChange, {
|
||||
args: [active],
|
||||
done() {
|
||||
emit('update:modelValue', active);
|
||||
emit('change', active);
|
||||
afterChange();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
linkChildren({ props, setActive });
|
||||
|
||||
@ -69,6 +69,34 @@ test('should match active tab by route path in route mode', async () => {
|
||||
expect(items[3].classes()).not.toContain(activeClass);
|
||||
});
|
||||
|
||||
test('should allow to use before-change prop in route mode', async () => {
|
||||
const wrapper = mount(
|
||||
{
|
||||
render: () => (
|
||||
<Tabbar route beforeChange={() => false}>
|
||||
<TabbarItem replace to="/">
|
||||
Tab
|
||||
</TabbarItem>
|
||||
<TabbarItem replace to="/search">
|
||||
Tab
|
||||
</TabbarItem>
|
||||
</Tabbar>
|
||||
),
|
||||
},
|
||||
{
|
||||
global: {
|
||||
mocks: getMockRouter(),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const items = wrapper.findAll('.van-tabbar-item');
|
||||
expect(items[0].classes()).toContain(activeClass);
|
||||
|
||||
await items[1].trigger('click');
|
||||
expect(items[1].classes()).not.toContain(activeClass);
|
||||
});
|
||||
|
||||
test('should match active tab by route name in route mode', async () => {
|
||||
const wrapper = mount(
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user