From 656ee4e5c9b363b6ab59aa071915414e5ee95de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E6=9C=A8?= Date: Sat, 11 Sep 2021 21:47:04 +0800 Subject: [PATCH] fix(upload): `accept` not work as expected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复basicUpload的accept属性未按预期工作的问题 --- CHANGELOG.zh_CN.md | 1 + src/components/Upload/src/useUpload.ts | 8 +++++++- src/views/demo/comp/upload/index.vue | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 4c43ef78..695db0b1 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -15,6 +15,7 @@ - 修复可编辑单元格的内容为空时,不会显示编辑图标的问题 - 修复表尾合计行与表格主体部分的列有时候未能对齐的问题 - **MarkDown** 修复初始 value 属性的值不起作用的问题 +- **BasicUpload** 修复`accept`属性不支持`MIME`及点开头的后缀名的问题 - **其它** - 修复部分封装组件在使用插槽时报错的问题 - 修复`useECharts`的`theme`参数不起作用的问题 diff --git a/src/components/Upload/src/useUpload.ts b/src/components/Upload/src/useUpload.ts index 213cc3a2..694cc275 100644 --- a/src/components/Upload/src/useUpload.ts +++ b/src/components/Upload/src/useUpload.ts @@ -22,7 +22,13 @@ export function useUploadType({ }); const getStringAccept = computed(() => { return unref(getAccept) - .map((item) => `.${item}`) + .map((item) => { + if (item.indexOf('/') > 0 || item.startsWith('.')) { + return item; + } else { + return `.${item}`; + } + }) .join(','); }); diff --git a/src/views/demo/comp/upload/index.vue b/src/views/demo/comp/upload/index.vue index d2241586..d619681e 100644 --- a/src/views/demo/comp/upload/index.vue +++ b/src/views/demo/comp/upload/index.vue @@ -7,6 +7,7 @@ @change="handleChange" :api="uploadApi" class="my-5" + :accept="['image/*']" />