feat: show image on upload
This commit is contained in:
parent
5442477e7d
commit
d7e606fb16
1 changed files with 12 additions and 0 deletions
|
|
@ -108,6 +108,18 @@ const inputFile = document.createElement('input');
|
|||
inputFile.type = 'file';
|
||||
inputFile.accept = 'image/*';
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.addEventListener('load', () => {
|
||||
if (typeof reader.result === 'string') {
|
||||
urlProfile.value = reader.result;
|
||||
}
|
||||
});
|
||||
|
||||
watch(profileFile, () => {
|
||||
if (profileFile.value) reader.readAsDataURL(profileFile.value);
|
||||
});
|
||||
|
||||
inputFile.addEventListener('change', (e) => {
|
||||
profileFile.value = (e.currentTarget as HTMLInputElement).files?.[0];
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue