data: () => ({
src: null,
}),
methods: {
onChange(e) {
const file = (e.target.files || e.dataTransfer.files)[0];
if (file) {
const reader = new FileReader();
reader.onload = () => this.src = reader.result;
reader.readAsDataURL(file);
}
},
},
<input type="file" @change="onChange">