mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 03:11:15 +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:
49
packages/tabbar-item/index.vue
Normal file
49
packages/tabbar-item/index.vue
Normal file
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<div :class="['van-tabbar-item', { 'van-tabbar-item--active': active }]" @click="onClick">
|
||||
<div :class="['van-tabbar-item__icon', { 'van-tabbar-item__icon-dot': dot }]">
|
||||
<slot name="icon">
|
||||
<van-icon v-if="icon" :name="icon" />
|
||||
</slot>
|
||||
</div>
|
||||
<div class="van-tabbar-item__text">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Icon from '../icon';
|
||||
|
||||
export default {
|
||||
name: 'van-tabbar-item',
|
||||
|
||||
components: {
|
||||
[Icon.name]: Icon
|
||||
},
|
||||
|
||||
props: {
|
||||
icon: String,
|
||||
dot: Boolean
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
active: false
|
||||
};
|
||||
},
|
||||
|
||||
beforeCreate() {
|
||||
this.$parent.items.push(this);
|
||||
},
|
||||
|
||||
destroyed() {
|
||||
this.$parent.items.splice(this.$parent.items.indexOf(this), 1);
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClick() {
|
||||
this.$parent.onChange(this.$parent.items.indexOf(this));
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Reference in New Issue
Block a user