Answer the question
In order to leave comments, you need to log in
How to trigger input change event on button click in Vue?
there is an input
<input
id="form-avatar"
type="file"
ref="uploadAvatar"
autocomplete="off"
accept="image/png,image/jpeg,image/bmp,image/tiff"
@change="onFileChange"
/>
<button
type="button"
class="btn btn-upload"
@click.prevent="changeUpload"
>
Загрузить
</button>
Answer the question
In order to leave comments, you need to log in
<button
type="button"
class="btn btn-upload"
@click.prevent="$refs.uploadAvatar.click()"
>
Загрузить
</button>
You have vue, in the changeUpload method you call the onFileChange method.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question