mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
62 lines
1.0 KiB
Vue
62 lines
1.0 KiB
Vue
<template>
|
|
<component
|
|
:is="tag"
|
|
:type="nativeType"
|
|
:disabled="disabled"
|
|
:class="b([
|
|
type,
|
|
size,
|
|
{
|
|
block,
|
|
loading,
|
|
disabled,
|
|
unclickable: disabled || loading,
|
|
'bottom-action': bottomAction
|
|
}
|
|
])"
|
|
@click="onClick"
|
|
>
|
|
<loading v-if="loading" size="20px" :color="type === 'default' ? 'black' : 'white'" />
|
|
<span :class="b('text')">
|
|
<slot>{{ text }}</slot>
|
|
</span>
|
|
</component>
|
|
</template>
|
|
|
|
<script>
|
|
import create from '../utils/create';
|
|
|
|
export default create({
|
|
name: 'button',
|
|
|
|
props: {
|
|
text: String,
|
|
block: Boolean,
|
|
loading: Boolean,
|
|
disabled: Boolean,
|
|
nativeType: String,
|
|
bottomAction: Boolean,
|
|
tag: {
|
|
type: String,
|
|
default: 'button'
|
|
},
|
|
type: {
|
|
type: String,
|
|
default: 'default'
|
|
},
|
|
size: {
|
|
type: String,
|
|
default: 'normal'
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
onClick(event) {
|
|
if (!this.loading && !this.disabled) {
|
|
this.$emit('click', event);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
</script>
|