refactor: edit addEventListener No waiting url
This commit is contained in:
parent
685ad0cc54
commit
1c467bff35
1 changed files with 4 additions and 5 deletions
|
|
@ -41,7 +41,10 @@ const inputFile = (() => {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
reader.addEventListener('load', () => {
|
reader.addEventListener('load', () => {
|
||||||
if (typeof reader.result === 'string') imageUrl.value = reader.result;
|
if (typeof reader.result === 'string') {
|
||||||
|
imageUrl.value = reader.result;
|
||||||
|
if (!dialogState.value) emit('save', file.value, imageUrl.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function browse() {
|
function browse() {
|
||||||
|
|
@ -51,13 +54,9 @@ function browse() {
|
||||||
function change(e: Event) {
|
function change(e: Event) {
|
||||||
const _element = e.target as HTMLInputElement | null;
|
const _element = e.target as HTMLInputElement | null;
|
||||||
const _file = _element?.files?.[0];
|
const _file = _element?.files?.[0];
|
||||||
|
|
||||||
if (_file) {
|
if (_file) {
|
||||||
file.value = _file;
|
file.value = _file;
|
||||||
reader.readAsDataURL(_file);
|
reader.readAsDataURL(_file);
|
||||||
if (!dialogState.value) {
|
|
||||||
emit('save', _file, imageUrl.value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue