123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <template>
- <view class="tui-divider" :style="{height:height+'rpx'}">
- <view class="tui-divider-line" :style="{width:width,background:getBgColor(gradual,gradualColor,dividerColor)}"></view>
- <view class="tui-divider-text" :style="{color:color,fontSize:size+'rpx',lineHeight:size+'rpx',background:bgcolor,fontWeight:bold?'bold':'normal'}">
- <slot></slot>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "tuiDivider",
- props: {
-
- height: {
- type: Number,
- default: 100
- },
-
- width: {
- type: String,
- default: "100%"
- },
-
- dividerColor: {
- type: String,
- default: "#e5e5e5"
- },
-
- color: {
- type: String,
- default: "#999"
- },
-
- size: {
- type: Number,
- default: 24
- },
- bold:{
- type: Boolean,
- default: false
- },
-
- bgcolor: {
- type: String,
- default: "#fafafa"
- },
-
- gradual: {
- type: Boolean,
- default: false
- },
-
- gradualColor: {
- type: Array,
- default: function() {
- return ["#eee", "#ccc"]
- }
- }
- },
- methods: {
- getBgColor: function(gradual, gradualColor, dividerColor) {
- let bgColor = dividerColor;
- if (gradual) {
- bgColor = "linear-gradient(to right," + gradualColor[0] + "," + gradualColor[1] + "," + gradualColor[1] + "," +
- gradualColor[0] + ")";
- }
- return bgColor;
- }
- }
- }
- </script>
- <style>
- .tui-divider {
- width: 100%;
- position: relative;
- text-align: center;
- display: flex;
- justify-content: center;
- align-items: center;
- box-sizing: border-box;
- overflow: hidden;
- }
- .tui-divider-line {
- position: absolute;
- height: 1rpx;
- top: 50%;
- left: 50%;
- -webkit-transform: scaleY(0.5) translateX(-50%) translateZ(0);
- transform: scaleY(0.5) translateX(-50%) translateZ(0);
- }
- .tui-divider-text {
- position: relative;
- text-align: center;
- padding: 0 18rpx;
- z-index: 1;
- }
- </style>
|