1
1
<template >
2
- <Button
3
- :size =" size"
4
- :text =" iconOnly ? '' : label"
5
- :icon =" icon"
6
- :iconOnly =" iconOnly"
7
- :isLoading =" loading"
8
- @click =" openCamera ? getFilesByCamera() : getFiles()"
9
- />
10
- <ion-input
11
- hidden
12
- class =" d-none"
13
- type =" file"
14
- ref =" fileInput"
15
- :multiple =" multiple"
16
- :accept =" `${accept};capture=camera`"
17
- @change =" filesChange"
18
- />
2
+ <div >
3
+ <Button
4
+ :size =" size"
5
+ :text =" iconOnly ? '' : label"
6
+ :icon =" icon"
7
+ :iconOnly =" iconOnly"
8
+ :isLoading =" loading"
9
+ @click =" openCamera ? getFilesByCamera() : getFiles()"
10
+ />
11
+ <ion-input
12
+ hidden
13
+ class =" d-none"
14
+ type =" file"
15
+ ref =" fileInput"
16
+ :multiple =" multiple"
17
+ :accept =" `${accept};capture=camera`"
18
+ @change =" filesChange"
19
+ />
20
+ </div >
19
21
</template >
20
22
21
23
<script >
@@ -75,7 +77,8 @@ export default {
75
77
},
76
78
methods: {
77
79
getFiles () {
78
- const fileInput = this .$refs .fileInput .$el .getElementsByTagName (' input' )[0 ];
80
+ const fileInput =
81
+ this .$refs .fileInput .$el .getElementsByTagName (' input' )[0 ];
79
82
fileInput .click ();
80
83
},
81
84
async getFilesByCamera () {
@@ -89,13 +92,15 @@ export default {
89
92
},
90
93
dataUriToBlob (dataURI ) {
91
94
const splitDataURI = dataURI .split (' ,' );
92
- const byteString = splitDataURI[0 ].indexOf (' base64' ) >= 0
93
- ? atob (splitDataURI[1 ])
94
- : decodeURI (splitDataURI[1 ]);
95
+ const byteString =
96
+ splitDataURI[0 ].indexOf (' base64' ) >= 0
97
+ ? atob (splitDataURI[1 ])
98
+ : decodeURI (splitDataURI[1 ]);
95
99
const mimeString = splitDataURI[0 ].split (' :' )[1 ].split (' ;' )[0 ];
96
100
97
101
const ia = new Uint8Array (byteString .length );
98
- for (let i = 0 ; i < byteString .length ; i++ ) ia[i] = byteString .charCodeAt (i);
102
+ for (let i = 0 ; i < byteString .length ; i++ )
103
+ ia[i] = byteString .charCodeAt (i);
99
104
100
105
return new Blob ([ia], { type: mimeString });
101
106
},
0 commit comments