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
| <template>
| <a-upload
| v-model:fileList="fileList"
| list-type="picture-card"
| :limit="limit"
| :action="action"
| @change="handleChange"
| image-preview
| />
| </template>
|
| <script setup>
| import { ref } from 'vue';
| const props = defineProps({
| limit: {
| type: Number,
| default: 1,
| },
| action: String, // 上传的服务器地址
| });
|
| const emit = defineEmits(['update:fileList', 'success']);
| const fileList = ref([]);
|
| const handleChange = (fileList) => {
| emit('update:fileList', fileList);
| const successFiles = fileList.filter((item) => item.status === 'done');
| if (successFiles.length > 0) {
| emit(
| 'success',
| successFiles.map((item) => item.response.data)
| );
| }
| };
| </script>
|
|