wangzhibo
2026-07-16 b57020623cf0c946706573bf102e548c3a544423
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
<template>
    <div>
        <el-divider content-position="left"> {{ $t('单选') }} </el-divider>
 
        <cl-upload-space v-model="v1" :multiple="false" accept="image/*" />
    </div>
 
    <div>
        <el-divider content-position="left"> {{ $t('多选') }} </el-divider>
 
        <cl-upload-space v-model="v2" :limit="3" accept="image/*" />
    </div>
 
    <div>
        <el-divider content-position="left"> {{ $t('自定义') }} </el-divider>
 
        <cl-upload-space
            :ref="setRefs('uploadSpace')"
            v-model="v3"
            :multiple="false"
            :show-btn="false"
            accept="image/*"
        >
            <div class="space-custom" @click="refs.uploadSpace?.open">
                <cl-avatar :size="50" :src="v3" />
                <p>{{ $t('选择头像') }}</p>
            </div>
        </cl-upload-space>
    </div>
</template>
 
<script lang="ts" setup>
import { ref } from 'vue';
import { useCool } from '/@/cool';
 
const { refs, setRefs } = useCool();
 
const v1 = ref('');
const v2 = ref<string[]>([]);
const v3 = ref('');
</script>
 
<style lang="scss" scoped>
.space-custom {
    border: 1px dashed var(--el-border-color);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 14px;
    box-sizing: border-box;
    height: 120px;
    width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
 
    p {
        margin-top: 10px;
    }
 
    &:hover {
        border-color: var(--el-color-primary);
    }
}
</style>