| | |
| | | import { VantComponent } from '../common/component'; |
| | | import { useParent } from '../common/relation'; |
| | | VantComponent({ |
| | | props: { |
| | | info: null, |
| | | name: null, |
| | | icon: String, |
| | | dot: Boolean, |
| | | iconPrefix: { |
| | | type: String, |
| | | value: 'van-icon', |
| | | }, |
| | | relation: { |
| | | name: 'tabbar', |
| | | type: 'ancestor', |
| | | current: 'tabbar-item', |
| | | }, |
| | | relation: useParent('tabbar'), |
| | | data: { |
| | | active: false, |
| | | activeColor: '', |
| | | inactiveColor: '', |
| | | }, |
| | | methods: { |
| | | onClick() { |
| | | if (this.parent) { |
| | | this.parent.onChange(this); |
| | | const { parent } = this; |
| | | if (parent) { |
| | | const index = parent.children.indexOf(this); |
| | | const active = this.data.name || index; |
| | | if (active !== this.data.active) { |
| | | parent.$emit('change', active); |
| | | } |
| | | } |
| | | this.$emit('click'); |
| | | }, |
| | |
| | | if (parentData.inactiveColor !== data.inactiveColor) { |
| | | patch.inactiveColor = parentData.inactiveColor; |
| | | } |
| | | return Object.keys(patch).length > 0 |
| | | ? this.set(patch) |
| | | : Promise.resolve(); |
| | | if (Object.keys(patch).length > 0) { |
| | | this.setData(patch); |
| | | } |
| | | }, |
| | | }, |
| | | }); |