2016-10-11 04:56:07 +00:00
|
|
|
<template>
|
2017-08-05 10:33:50 +00:00
|
|
|
<button
|
|
|
|
class="el-button"
|
2016-10-28 09:29:18 +00:00
|
|
|
@click="handleClick"
|
2017-10-04 12:44:56 +00:00
|
|
|
:disabled="disabled"
|
|
|
|
:autofocus="autofocus"
|
2016-10-11 04:56:07 +00:00
|
|
|
:type="nativeType"
|
|
|
|
:class="[
|
2016-10-25 03:33:39 +00:00
|
|
|
type ? 'el-button--' + type : '',
|
|
|
|
size ? 'el-button--' + size : '',
|
2016-10-11 04:56:07 +00:00
|
|
|
{
|
|
|
|
'is-disabled': disabled,
|
|
|
|
'is-loading': loading,
|
2017-08-23 10:07:14 +00:00
|
|
|
'is-plain': plain,
|
|
|
|
'is-round': round
|
2016-10-11 04:56:07 +00:00
|
|
|
}
|
|
|
|
]"
|
|
|
|
>
|
2017-08-11 10:11:56 +00:00
|
|
|
<i class="el-icon-loading" v-if="loading" @click="handleInnerClick"></i>
|
2017-09-28 07:28:12 +00:00
|
|
|
<i :class="icon" v-if="icon && !loading" @click="handleInnerClick"></i>
|
2017-08-11 10:11:56 +00:00
|
|
|
<span v-if="$slots.default" @click="handleInnerClick"><slot></slot></span>
|
2016-10-11 04:56:07 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'ElButton',
|
|
|
|
|
|
|
|
props: {
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: 'default'
|
|
|
|
},
|
|
|
|
size: String,
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
nativeType: {
|
|
|
|
type: String,
|
|
|
|
default: 'button'
|
|
|
|
},
|
2016-10-30 08:12:16 +00:00
|
|
|
loading: Boolean,
|
|
|
|
disabled: Boolean,
|
|
|
|
plain: Boolean,
|
2017-08-23 10:07:14 +00:00
|
|
|
autofocus: Boolean,
|
|
|
|
round: Boolean
|
2016-10-28 09:29:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
handleClick(evt) {
|
|
|
|
this.$emit('click', evt);
|
2017-08-11 10:11:56 +00:00
|
|
|
},
|
|
|
|
handleInnerClick(evt) {
|
|
|
|
if (this.disabled) {
|
|
|
|
evt.stopPropagation();
|
|
|
|
}
|
2016-10-28 09:29:18 +00:00
|
|
|
}
|
2016-10-11 04:56:07 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|