mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 01:54:48 +00:00
[new feature] add Tabbar component (#204)
* [Document] add english document of Checkbox * [Document] add english document of Field * [Document] add english document of NumberKeyboard * [bugfix] NumberKeyboard should not dispaly title when title is empty * [Document] add english document of PasswordInput * [Document] add english document of Radio * [document] add english document of Switch * [bugfix] remove redundent styles in english document * [Document] fix details * fix Switch test cases * [bugfix] Swipe shouid reinitialize when item changes * [new feature] ImagePreview reconstruct * [new feature] add Tabbar component
This commit is contained in:
46
packages/tabbar/index.vue
Normal file
46
packages/tabbar/index.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<div :class="['van-tabbar', 'van-hairline--top-bottom', { 'van-tabbar--fixed': fixed }]">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'van-tabbar',
|
||||
|
||||
data() {
|
||||
return {
|
||||
items: []
|
||||
};
|
||||
},
|
||||
|
||||
props: {
|
||||
value: Number,
|
||||
fixed: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
items() {
|
||||
this.setActiveItem();
|
||||
},
|
||||
value() {
|
||||
this.setActiveItem();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
setActiveItem() {
|
||||
this.items.forEach((item, index) => {
|
||||
item.active = index === this.value;
|
||||
});
|
||||
},
|
||||
onChange(active) {
|
||||
this.$emit('input', active);
|
||||
this.$emit('change', active);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Reference in New Issue
Block a user