mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-08 23:44:44 +00:00
35 lines
789 B
Vue
35 lines
789 B
Vue
|
|
<template>
|
||
|
|
<div class="md-button-group md-button-toggle">
|
||
|
|
<slot></slot>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<style lang="scss" src="./mdButtonToggle.scss"></style>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
let onClickButton;
|
||
|
|
|
||
|
|
export default {
|
||
|
|
ready() {
|
||
|
|
this.$children.forEach((child) => {
|
||
|
|
let element = child.$el;
|
||
|
|
|
||
|
|
if (element && element.classList.contains('md-button')) {
|
||
|
|
element.addEventListener('click', onClickButton = () => {
|
||
|
|
element.classList.toggle('md-toggle');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
beforeDestroy() {
|
||
|
|
this.$children.forEach((child) => {
|
||
|
|
let element = child.$el;
|
||
|
|
|
||
|
|
if (element && element.classList.contains('md-button')) {
|
||
|
|
child.removeEventListener('click', onClickButton);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
};
|
||
|
|
</script>
|