iview/src/components/divider/divider.vue

58 lines
1.6 KiB
Vue
Raw Normal View History

<template>
2018-06-20 11:31:38 +08:00
<div :class="classes">
<span v-if="hasSlot" :class="slotClasses">
<slot></slot>
</span>
</div>
</template>
<script>
2018-06-20 11:31:38 +08:00
import {oneOf} from '../../utils/assist';
2018-06-20 11:31:38 +08:00
const prefixCls = 'ivu-divider';
2018-06-20 11:31:38 +08:00
export default {
name: 'Divider',
props: {
type: {
type: String,
default: 'horizontal',
validator (value) {
return oneOf(value, ['horizontal', 'vertical']);
}
},
orientation: {
type: String,
2018-06-20 11:47:36 +08:00
default: 'center',
2018-06-20 11:31:38 +08:00
validator (value) {
2018-06-20 11:47:36 +08:00
return oneOf(value, ['left', 'right', 'center']);
2018-06-20 11:31:38 +08:00
}
},
dashed: {
type: Boolean,
default: false,
}
},
computed: {
hasSlot() {
return !!this.$slots.default;
},
classes() {
return [
`${prefixCls}`,
`${prefixCls}-${this.type}`,
{
2019-01-02 12:01:26 +08:00
[`${prefixCls}-with-text`]: this.hasSlot && this.orientation === 'center',
2018-06-20 11:31:38 +08:00
[`${prefixCls}-with-text-${this.orientation}`]: this.hasSlot,
[`${prefixCls}-dashed`]: !!this.dashed
}
];
},
slotClasses() {
return [
`${prefixCls}-inner-text`,
2018-06-21 09:15:00 +08:00
];
2018-06-20 11:31:38 +08:00
}
}
2018-06-21 09:15:00 +08:00
};
2018-06-20 11:31:38 +08:00
</script>