iview/src/components/spin/spin.vue

60 lines
1.5 KiB
Vue
Raw Normal View History

2016-09-09 14:29:19 +08:00
<template>
2017-03-06 13:43:15 +08:00
<transition name="fade">
<div :class="classes">
<div :class="mainClasses">
<span :class="dotClasses"></span>
<div :class="textClasses"><slot></slot></div>
</div>
2016-09-09 14:29:19 +08:00
</div>
2017-03-06 13:43:15 +08:00
</transition>
2016-09-09 14:29:19 +08:00
</template>
<script>
import { oneOf } from '../../utils/assist';
const prefixCls = 'ivu-spin';
export default {
2017-03-06 17:30:39 +08:00
name: 'Spin',
2016-09-09 14:29:19 +08:00
props: {
size: {
validator (value) {
return oneOf(value, ['small', 'large']);
}
},
fix: {
type: Boolean,
default: false
}
},
data () {
return {
showText: false
2016-12-25 22:49:42 +08:00
};
2016-09-09 14:29:19 +08:00
},
computed: {
classes () {
return [
`${prefixCls}`,
{
[`${prefixCls}-${this.size}`]: !!this.size,
[`${prefixCls}-fix`]: this.fix,
[`${prefixCls}-show-text`]: this.showText,
}
2016-12-25 22:49:42 +08:00
];
2016-09-09 14:29:19 +08:00
},
mainClasses () {
return `${prefixCls}-main`;
},
dotClasses () {
return `${prefixCls}-dot`;
},
textClasses () {
return `${prefixCls}-text`;
}
},
2017-03-06 13:43:15 +08:00
mounted () {
this.showText = this.$slots.default !== undefined;
2016-09-09 14:29:19 +08:00
}
2016-12-25 22:49:42 +08:00
};
</script>