wangzhibo
2026-08-16 10595d8632f959d0954d1939243196f4eed02372
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
    <view
        class="cl-card"
        :style="{
            backgroundColor,
        }"
    >
        <view class="cl-card__header" v-if="label">
            <cl-text :size="28" bold :value="label"></cl-text>
 
            <view class="cl-card__loading" v-if="loading">
                <cl-loading :size="36" :loading="loading"></cl-loading>
            </view>
 
            <template v-else>
                <view class="cl-card__more" v-if="more" @tap="toMore">
                    <slot name="more">
                        <text class="text">{{ moreText }}</text>
                        <text class="cl-icon-arrow-right"></text>
                    </slot>
                </view>
            </template>
        </view>
 
        <view class="cl-card__container">
            <slot></slot>
        </view>
 
        <view class="cl-card__footer" v-if="$slots.footer">
            <slot name="footer"></slot>
        </view>
    </view>
</template>
 
<script lang="ts">
import { defineComponent } from "vue";
 
export default defineComponent({
    name: "cl-card",
 
    props: {
        // 标签内容
        label: String,
        // 是否加载中
        loading: Boolean,
        // 是否显示查看更多
        more: Boolean,
        // 更多的文本内容
        moreText: String,
        // 背景色
        backgroundColor: {
            type: String,
            default: "#ffffff",
        },
    },
 
    setup(_, { emit }) {
        function toMore() {
            emit("more");
        }
 
        return {
            toMore,
        };
    },
});
</script>