From cd5534c20a5e8f085174149bd2bcc5cc2c66a3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=E6=80=80=E7=A3=8A=E2=80=9D?= <2280131253@qq.com> Date: Tue, 18 Jan 2022 19:32:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B3=BB=E7=BB=9F=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0ssh=E5=8D=8F=E8=AE=AEi18n=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/FormFields/UploadKey.vue | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/FormFields/UploadKey.vue b/src/components/FormFields/UploadKey.vue index a90049dbd..3d79269ba 100644 --- a/src/components/FormFields/UploadKey.vue +++ b/src/components/FormFields/UploadKey.vue @@ -1,6 +1,10 @@ @@ -21,12 +25,22 @@ export default { default: () => 'string' } }, + data() { + return { + fileName: '' + } + }, methods: { + onUpLoad() { + this.$refs.upLoadFile.click() + }, onChange(e) { - if (e.target.files.length === 0) { + const upLoadFile = e.target.files + if (upLoadFile.length === 0) { return } const vm = this + this.fileName = upLoadFile[0].name || '' const reader = new FileReader() reader.onload = function() { let result = this.result @@ -36,7 +50,7 @@ export default { vm.$emit('input', result) } reader.readAsText( - e.target.files[0] + upLoadFile[0] ) } }