perf(SidebarItem): move onClick fn

This commit is contained in:
chenjiahan 2020-08-26 13:22:35 +08:00
parent f9226cdfac
commit e045fb1596

View File

@ -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')}>