mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
import { createNamespace } from '../utils';
|
|
import { ChildrenMixin } from '../mixins/relation';
|
|
import { route, routeProps } from '../utils/router';
|
|
import Info from '../info';
|
|
|
|
const [createComponent, bem] = createNamespace('sidebar-item');
|
|
|
|
export default createComponent({
|
|
mixins: [ChildrenMixin('vanSidebar')],
|
|
|
|
emits: ['click'],
|
|
|
|
props: {
|
|
...routeProps,
|
|
dot: Boolean,
|
|
badge: [Number, String],
|
|
title: String,
|
|
disabled: Boolean,
|
|
},
|
|
|
|
computed: {
|
|
select() {
|
|
return this.index === +this.parent.modelValue;
|
|
},
|
|
},
|
|
|
|
methods: {
|
|
onClick() {
|
|
if (this.disabled) {
|
|
return;
|
|
}
|
|
|
|
this.$emit('click', this.index);
|
|
this.parent.$emit('update:modelValue', this.index);
|
|
this.parent.setIndex(this.index);
|
|
route(this.$router, this);
|
|
},
|
|
},
|
|
|
|
render() {
|
|
return (
|
|
<a
|
|
class={bem({ select: this.select, disabled: this.disabled })}
|
|
onClick={this.onClick}
|
|
>
|
|
<div class={bem('text')}>
|
|
{this.title}
|
|
<Info dot={this.dot} info={this.badge} class={bem('info')} />
|
|
</div>
|
|
</a>
|
|
);
|
|
},
|
|
});
|