mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-25 07:13:45 +00:00
Improve md button toogle
This commit is contained in:
parent
72898eed46
commit
1075827afa
2 changed files with 17 additions and 5 deletions
|
|
@ -79,8 +79,7 @@ $button-icon-size: 40px;
|
|||
}
|
||||
|
||||
&.md-icon-button {
|
||||
width: $button-icon-size;
|
||||
min-width: 0;
|
||||
min-width: $button-icon-size;
|
||||
height: $button-icon-size;
|
||||
margin: 0 6px;
|
||||
padding: 8px;
|
||||
|
|
|
|||
|
|
@ -10,14 +10,27 @@
|
|||
let onClickButton;
|
||||
|
||||
export default {
|
||||
props: {
|
||||
type: String
|
||||
},
|
||||
ready() {
|
||||
this.$children.forEach((child) => {
|
||||
let element = child.$el;
|
||||
|
||||
if (element && element.classList.contains('md-button')) {
|
||||
element.addEventListener('click', onClickButton = () => {
|
||||
onClickButton = () => {
|
||||
if (this.type === 'radio') {
|
||||
this.$children.forEach((child) => {
|
||||
child.$el.classList.remove('md-toggle');
|
||||
});
|
||||
|
||||
element.classList.add('md-toggle');
|
||||
} else {
|
||||
element.classList.toggle('md-toggle');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (element && element.classList.contains('md-button')) {
|
||||
element.addEventListener('click', onClickButton);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue