7fa943eb
梁灏
init
|
1
2
|
<template>
<button :type="htmlType" :class="classes" :disabled="disabled">
|
9817ce99
jingsam
Use Icon...
|
3
4
|
<Icon class="ivu-load-loop" type="load-c" v-if="loading"></Icon>
<Icon :type="icon" v-if="icon && !loading"></Icon>
|
d47ea998
梁灏
support Button an...
|
5
|
<span v-if="showSlot" ref="slot"><slot></slot></span>
|
7fa943eb
梁灏
init
|
6
7
8
9
10
11
12
|
</button>
</template>
<script>
import Icon from '../icon';
import { oneOf } from '../../utils/assist';
const prefixCls = 'ivu-btn';
|
7fa943eb
梁灏
init
|
13
14
|
export default {
|
06322514
梁灏
support Radio
|
15
|
name: 'Button',
|
7fa943eb
梁灏
init
|
16
17
18
19
|
components: { Icon },
props: {
type: {
validator (value) {
|
b88f42eb
梁灏
Button add 4 new ...
|
20
|
return oneOf(value, ['primary', 'ghost', 'dashed', 'text', 'info', 'success', 'warning', 'error']);
|
7fa943eb
梁灏
init
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
}
},
shape: {
validator (value) {
return oneOf(value, ['circle', 'circle-outline']);
}
},
size: {
validator (value) {
return oneOf(value, ['small', 'large']);
}
},
loading: Boolean,
disabled: Boolean,
htmlType: {
default: 'button',
validator (value) {
return oneOf(value, ['button', 'submit', 'reset']);
}
},
|
71d9fc8e
梁灏
Button add new pr...
|
41
42
43
44
45
|
icon: String,
long: {
type: Boolean,
default: false
}
|
7fa943eb
梁灏
init
|
46
|
},
|
698e3b61
梁灏
iButton add some ...
|
47
48
49
|
data () {
return {
showSlot: true
|
b0893113
jingsam
add eslint
|
50
|
};
|
698e3b61
梁灏
iButton add some ...
|
51
|
},
|
7fa943eb
梁灏
init
|
52
53
54
55
56
57
|
computed: {
classes () {
return [
`${prefixCls}`,
{
[`${prefixCls}-${this.type}`]: !!this.type,
|
71d9fc8e
梁灏
Button add new pr...
|
58
|
[`${prefixCls}-long`]: this.long,
|
7fa943eb
梁灏
init
|
59
60
|
[`${prefixCls}-${this.shape}`]: !!this.shape,
[`${prefixCls}-${this.size}`]: !!this.size,
|
698e3b61
梁灏
iButton add some ...
|
61
62
|
[`${prefixCls}-loading`]: this.loading != null && this.loading,
[`${prefixCls}-icon-only`]: !this.showSlot && (!!this.icon || this.loading)
|
7fa943eb
梁灏
init
|
63
|
}
|
b0893113
jingsam
add eslint
|
64
|
];
|
7fa943eb
梁灏
init
|
65
|
}
|
698e3b61
梁灏
iButton add some ...
|
66
|
},
|
d47ea998
梁灏
support Button an...
|
67
68
|
mounted () {
this.showSlot = this.$refs.slot.innerHTML.replace(/\n/g, '').replace(/<!--[\w\W\r\n]*?-->/gmi, '') !== '';
|
7fa943eb
梁灏
init
|
69
|
}
|
b0893113
jingsam
add eslint
|
70
|
};
|
d6342fe1
jingsam
fixed ie bug
|
71
|
</script>
|