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>
|
698e3b61
梁灏
iButton add some ...
|
5
|
<span v-if="showSlot" v-el: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
15
16
17
18
|
export default {
components: { Icon },
props: {
type: {
validator (value) {
|
b88f42eb
梁灏
Button add 4 new ...
|
19
|
return oneOf(value, ['primary', 'ghost', 'dashed', 'text', 'info', 'success', 'warning', 'error']);
|
7fa943eb
梁灏
init
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
}
},
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...
|
40
41
42
43
44
|
icon: String,
long: {
type: Boolean,
default: false
}
|
7fa943eb
梁灏
init
|
45
|
},
|
698e3b61
梁灏
iButton add some ...
|
46
47
48
|
data () {
return {
showSlot: true
|
b0893113
jingsam
add eslint
|
49
|
};
|
698e3b61
梁灏
iButton add some ...
|
50
|
},
|
7fa943eb
梁灏
init
|
51
52
53
54
55
56
|
computed: {
classes () {
return [
`${prefixCls}`,
{
[`${prefixCls}-${this.type}`]: !!this.type,
|
71d9fc8e
梁灏
Button add new pr...
|
57
|
[`${prefixCls}-long`]: this.long,
|
7fa943eb
梁灏
init
|
58
59
|
[`${prefixCls}-${this.shape}`]: !!this.shape,
[`${prefixCls}-${this.size}`]: !!this.size,
|
698e3b61
梁灏
iButton add some ...
|
60
61
|
[`${prefixCls}-loading`]: this.loading != null && this.loading,
[`${prefixCls}-icon-only`]: !this.showSlot && (!!this.icon || this.loading)
|
7fa943eb
梁灏
init
|
62
|
}
|
b0893113
jingsam
add eslint
|
63
|
];
|
7fa943eb
梁灏
init
|
64
|
}
|
698e3b61
梁灏
iButton add some ...
|
65
|
},
|
71d9fc8e
梁灏
Button add new pr...
|
66
|
compiled () {
|
77f7bb95
梁灏
add Transfer comp...
|
67
|
this.showSlot = this.$els.slot.innerHTML.replace(/\n/g, '').replace(/<!--[\w\W\r\n]*?-->/gmi, '') !== '';
|
7fa943eb
梁灏
init
|
68
|
}
|
b0893113
jingsam
add eslint
|
69
|
};
|
d6342fe1
jingsam
fixed ie bug
|
70
|
</script>
|