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

This commit is contained in:
无木 2021-06-30 17:02:50 +08:00
parent 76a5f87c0c
commit 16c5d327f1
2 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,7 @@
- **Axios** 新增`withToken`配置,用于控制请求是否携带 token - **Axios** 新增`withToken`配置,用于控制请求是否携带 token
- **BasicUpload** 新增在预览 `Modal` 中删除文件时触发`preview-delete` 事件 - **BasicUpload** 新增在预览 `Modal` 中删除文件时触发`preview-delete` 事件
- **BasicUpload** `value` 支持 `v-model` 用法
### 🐛 Bug Fixes ### 🐛 Bug Fixes

View File

@ -51,7 +51,7 @@
name: 'BasicUpload', name: 'BasicUpload',
components: { UploadModal, UploadPreviewModal, Icon, Tooltip }, components: { UploadModal, UploadPreviewModal, Icon, Tooltip },
props: uploadContainerProps, props: uploadContainerProps,
emits: ['change', 'delete', 'preview-delete'], emits: ['change', 'delete', 'preview-delete', 'update:value'],
setup(props, { emit, attrs }) { setup(props, { emit, attrs }) {
const { t } = useI18n(); const { t } = useI18n();
@ -85,12 +85,14 @@
// modal // modal
function handleChange(urls: string[]) { function handleChange(urls: string[]) {
fileList.value = [...unref(fileList), ...(urls || [])]; fileList.value = [...unref(fileList), ...(urls || [])];
emit('update:value', fileList.value);
emit('change', fileList.value); emit('change', fileList.value);
} }
// modal // modal
function handlePreviewChange(urls: string[]) { function handlePreviewChange(urls: string[]) {
fileList.value = [...(urls || [])]; fileList.value = [...(urls || [])];
emit('update:value', fileList.value);
emit('change', fileList.value); emit('change', fileList.value);
} }