Browse Source

添加上传文件大小限制

lex-xin 2 months ago
parent
commit
137e9ac77a
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/pc/home/index.tsx

+ 7 - 0
src/pc/home/index.tsx

@@ -1897,6 +1897,13 @@ export default defineComponent({
 
         const file = e.target.files[0];
         if (val === "xml") {
+          const size = file.size || 0
+          const isLt2M = size / 1024 / 1024 < 6;
+          if (!isLt2M) {
+            message.error(`文件大小不能超过6M`);
+            data.loadingAudioSrouce2 = false;
+            return;
+          }
           const reader = new FileReader();
           reader.onload = async (e: any) => {
             // let abc = e.target.result;