Button: avoid click event bubbling when disabled

This commit is contained in:
Leopoldthecoder 2017-08-11 18:11:56 +08:00 committed by 杨奕
parent dc77b56d31
commit e289e86154

View File

@ -13,9 +13,9 @@
}
]"
>
<i class="el-icon-loading" v-if="loading"></i>
<i :class="'el-icon-' + icon" v-if="icon && !loading"></i>
<span v-if="$slots.default"><slot></slot></span>
<i class="el-icon-loading" v-if="loading" @click="handleInnerClick"></i>
<i :class="'el-icon-' + icon" v-if="icon && !loading" @click="handleInnerClick"></i>
<span v-if="$slots.default" @click="handleInnerClick"><slot></slot></span>
</button>
</template>
<script>
@ -45,6 +45,11 @@
methods: {
handleClick(evt) {
this.$emit('click', evt);
},
handleInnerClick(evt) {
if (this.disabled) {
evt.stopPropagation();
}
}
}
};