[Vuejs]-Vue.js Element-UI and axios file upload causing page refresh

0👍

I wonder if it has a default behavior like a form submit happening. If there were no href property it would reload the page. Is there an event you can tap into like onClick(e)? Then in the function that handles it do e.preventDefault();

https://www.w3schools.com/jsref/event_preventdefault.asp

0👍

Element-ui upload can upload the file for you, then there is no page refresh:

el-upload(:action="formUploadLocation" :data="form" :auto-upload="false" ref="upload" :file-list="list"
          :on-success="handleSucces" :on-error="handleFail"

Then the upload in the form submit (only when :auto-upload=false):

this.$refs.upload.submit()

Leave a comment