mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
perf(SidebarItem): move onClick fn
This commit is contained in:
parent
f9226cdfac
commit
e045fb1596
@ -21,21 +21,21 @@ export default createComponent({
|
||||
const route = useRoute();
|
||||
const { parent, index } = useParent(SIDEBAR_KEY);
|
||||
|
||||
const onClick = () => {
|
||||
if (props.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit('click', index.value);
|
||||
parent.emit('update:modelValue', index.value);
|
||||
parent.setActive(index.value);
|
||||
route();
|
||||
};
|
||||
|
||||
return () => {
|
||||
const { dot, badge, title, disabled } = props;
|
||||
const selected = index.value === parent.active();
|
||||
|
||||
const onClick = () => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit('click', index.value);
|
||||
parent.emit('update:modelValue', index.value);
|
||||
parent.setActive(index.value);
|
||||
route();
|
||||
};
|
||||
|
||||
return (
|
||||
<a class={bem({ select: selected, disabled })} onClick={onClick}>
|
||||
<div class={bem('text')}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user