Commit 16c5d327f1209f7c7437acde2ab0fa031da6a641

Authored by 无木
1 parent 76a5f87c

feat(basic-upload): `value` support v-model

CHANGELOG.zh_CN.md
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 - **Axios** 新增`withToken`配置,用于控制请求是否携带 token 3 - **Axios** 新增`withToken`配置,用于控制请求是否携带 token
4 - **BasicUpload** 新增在预览 `Modal` 中删除文件时触发`preview-delete` 事件 4 - **BasicUpload** 新增在预览 `Modal` 中删除文件时触发`preview-delete` 事件
  5 +- **BasicUpload** `value` 支持 `v-model` 用法
5 6
6 ### 🐛 Bug Fixes 7 ### 🐛 Bug Fixes
7 8
src/components/Upload/src/BasicUpload.vue
@@ -51,7 +51,7 @@ @@ -51,7 +51,7 @@
51 name: 'BasicUpload', 51 name: 'BasicUpload',
52 components: { UploadModal, UploadPreviewModal, Icon, Tooltip }, 52 components: { UploadModal, UploadPreviewModal, Icon, Tooltip },
53 props: uploadContainerProps, 53 props: uploadContainerProps,
54 - emits: ['change', 'delete', 'preview-delete'], 54 + emits: ['change', 'delete', 'preview-delete', 'update:value'],
55 55
56 setup(props, { emit, attrs }) { 56 setup(props, { emit, attrs }) {
57 const { t } = useI18n(); 57 const { t } = useI18n();
@@ -85,12 +85,14 @@ @@ -85,12 +85,14 @@
85 // 上传modal保存操作 85 // 上传modal保存操作
86 function handleChange(urls: string[]) { 86 function handleChange(urls: string[]) {
87 fileList.value = [...unref(fileList), ...(urls || [])]; 87 fileList.value = [...unref(fileList), ...(urls || [])];
  88 + emit('update:value', fileList.value);
88 emit('change', fileList.value); 89 emit('change', fileList.value);
89 } 90 }
90 91
91 // 预览modal保存操作 92 // 预览modal保存操作
92 function handlePreviewChange(urls: string[]) { 93 function handlePreviewChange(urls: string[]) {
93 fileList.value = [...(urls || [])]; 94 fileList.value = [...(urls || [])];
  95 + emit('update:value', fileList.value);
94 emit('change', fileList.value); 96 emit('change', fileList.value);
95 } 97 }
96 98