mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-03 04:54:43 +00:00
add 'changed' event to mdBottomBar. (#296)
Now we fire off an event when the active item changes, just like mdTabs. Additionally, this moves activation logic to mdBottomBar, instead of each mdBottomBarItem. It made the change easier to implement, and seems a bit cleaner, though that's subjective.
This commit is contained in:
parent
d080cdde6b
commit
26dc2145ec
3 changed files with 30 additions and 5 deletions
|
|
@ -30,6 +30,24 @@
|
|||
</md-table-row>
|
||||
</md-table-body>
|
||||
</md-table>
|
||||
|
||||
<md-table slot="events">
|
||||
<md-table-header>
|
||||
<md-table-row>
|
||||
<md-table-head>Name</md-table-head>
|
||||
<md-table-head>Value</md-table-head>
|
||||
<md-table-head>Description</md-table-head>
|
||||
</md-table-row>
|
||||
</md-table-header>
|
||||
|
||||
<md-table-body>
|
||||
<md-table-row>
|
||||
<md-table-cell>change</md-table-cell>
|
||||
<md-table-cell>Receive the item index</md-table-cell>
|
||||
<md-table-cell>Triggered when an item is activated.</md-table-cell>
|
||||
</md-table-row>
|
||||
</md-table-body>
|
||||
</md-table>
|
||||
</api-table>
|
||||
|
||||
<api-table name="md-bottom-bar-item">
|
||||
|
|
|
|||
|
|
@ -18,6 +18,15 @@
|
|||
classes() {
|
||||
return this.mdShift ? 'md-shift' : 'md-fixed';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setActive(item) {
|
||||
this.$children.forEach((child) => {
|
||||
child.active = child === item;
|
||||
});
|
||||
|
||||
this.$emit('change', this.$children.findIndex((i) => i === item));
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -47,11 +47,9 @@
|
|||
},
|
||||
methods: {
|
||||
setActive(active) {
|
||||
this.$parent.$children.forEach((item) => {
|
||||
item.active = false;
|
||||
});
|
||||
|
||||
this.active = !!active;
|
||||
if (active) {
|
||||
this.$parent.setActive(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue