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', () => {
|
||||
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() {
|
||||
|
|
@ -51,13 +54,9 @@ function browse() {
|
|||
function change(e: Event) {
|
||||
const _element = e.target as HTMLInputElement | null;
|
||||
const _file = _element?.files?.[0];
|
||||
|
||||
if (_file) {
|
||||
file.value = _file;
|
||||
reader.readAsDataURL(_file);
|
||||
if (!dialogState.value) {
|
||||
emit('save', _file, imageUrl.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue