1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
| <template>
| <view class="cl-divider">
| <view class="cl-divider__line" :style="{ background: lineColor, width }"></view>
|
| <view
| class="cl-divider__text"
| :style="{
| backgroundColor,
| }"
| >
| <slot></slot>
| </view>
| </view>
| </template>
|
| <script lang="ts">
| import { computed, defineComponent } from "vue";
| import { isArray } from "lodash-es";
|
| export default defineComponent({
| name: "cl-divider",
|
| props: {
| // 背景颜色
| backgroundColor: String,
| // 线条颜色
| color: {
| type: [String, Array],
| default: "#dcdfe6",
| },
| // 线条宽度
| width: {
| type: String,
| default: "100%",
| },
| },
|
| setup(props) {
| const lineColor = computed(() => {
| if (isArray(props.color)) {
| const [a, b] = props.color || [];
| return `linear-gradient(to right, ${a}, ${b}, ${b}, ${a})`;
| } else {
| return props.color;
| }
| });
|
| return {
| lineColor,
| };
| },
| });
| </script>
|
|