From b6861e1ae7f114737a7b383fc4ab0dba3653b01e Mon Sep 17 00:00:00 2001 From: he wei <858544502@qq.com> Date: 星期五, 18 三月 2022 18:05:06 +0800 Subject: [PATCH] U 修复不能拖文件进去的问题 --- src/main/demo/src/views/selectFile.vue | 34 +++++++++++++++++++++++++--------- 1 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main/demo/src/views/selectFile.vue b/src/main/demo/src/views/selectFile.vue index ee976bc..90f7570 100644 --- a/src/main/demo/src/views/selectFile.vue +++ b/src/main/demo/src/views/selectFile.vue @@ -6,13 +6,12 @@ drag :auto-upload="false" :on-change="change" + @drop.native="drop" accept=".fbx" > <!-- <i class="icon el-icon-plus"></i> --> - <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴栫偣鍑绘澶勯�夋嫨鏂囦欢</div> - <div class="el-upload__tip" slot="tip"> - 鍙兘瑙f瀽.fbx鏂囦欢 - </div> + <div class="el-upload__text">灏�.fbx鏂囦欢鎷栧埌姝ゅ锛屾垨鐐瑰嚮姝ゅ閫夋嫨鏂囦欢</div> + <div class="el-upload__tip" slot="tip">鍙兘瑙f瀽.fbx鏂囦欢</div> </el-upload> </div> </template> @@ -33,26 +32,29 @@ change(file) { // let $el = this.$refs.input; // console.log($el.files[0].path); - if (!file || !file.raw || !file.raw.path) { + if (!file || !file.raw) { return false; } console.log(file); - if (!/\.fbx$/.test(file.raw.name.toLowerCase().trim())) { - this.$layer.msg('绫诲瀷閿欒'); + this.loadFile(file.raw); + }, + loadFile(file) { + if (!/\.fbx$/.test(file.name.toLowerCase().trim())) { + this.$layer.msg("绫诲瀷閿欒"); return false; } axios({ url: "readFboFile", method: "POST", params: { - filePath: file.raw.path, + filePath: file.path, }, }).then((res) => { res = res.data; console.log(res, res.code, "=========res"); if (res.code) { let data = res.data; - data.filePath = file.raw.path; + data.filePath = file.path; // 瑙f瀽鎴愬姛 璺宠浆鍒扮粨鏋滈〉闈� this.$router.push({ path: "/result", @@ -63,6 +65,20 @@ } }); }, + drop(e) { + // console.log(e); + //蹇呴』瑕侀樆姝㈡嫋鎷界殑榛樿浜嬩欢 + e.preventDefault(); + e.stopPropagation(); + + //鑾峰緱鎷栨嫿鐨勬枃浠堕泦鍚� + var files = e.dataTransfer.files; + console.log(files); + if (!files) { + return false; + } + this.loadFile(files[0]); + }, }, mounted() {}, -- Gitblit v1.9.1