feat: migrate Sidebar component

This commit is contained in:
chenjiahan
2020-07-12 15:24:05 +08:00
parent 75d76d2cec
commit 08e03e988f
11 changed files with 649 additions and 1 deletions
+40
View File
@@ -0,0 +1,40 @@
import { createNamespace } from '../utils';
import { ParentMixin } from '../mixins/relation';
const [createComponent, bem] = createNamespace('sidebar');
export default createComponent({
mixins: [ParentMixin('vanSidebar')],
props: {
modelValue: {
type: [Number, String],
default: 0,
},
},
data() {
return {
index: +this.modelValue,
};
},
watch: {
modelValue() {
this.setIndex(+this.modelValue);
},
},
methods: {
setIndex(index) {
if (index !== this.index) {
this.index = index;
this.$emit('change', index);
}
},
},
render() {
return <div class={bem()}>{this.$slots.default?.()}</div>;
},
});