iview/src/components/divider/divider.vue

57 lines
1.5 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}`,
{
[`${prefixCls}-with-text-${this.orientation}`]: this.hasSlot,
[`${prefixCls}-dashed`]: !!this.dashed
}
];
},
slotClasses() {
return [
`${prefixCls}-inner-text`,
]
}
}
}
2018-06-20 11:31:38 +08:00
</script>