0π
β
I use Visual Studio to open the port, and I found that separating the upload path and the web page path prevents the webpage from refreshing. Although Iβm not sure why this happens, I have successfully resolved this issue.
0π
The webpage refreshes after executing the "save()" function in Django because the form submission is triggering a default behavior of refreshing the page. To prevent this, you can modify your Vue code by removing the "onsubmit" attribute from the form tag and handling the form submission using the Vue method.
Hereβs the updated code:
<form>
<input type="file" ref="fileInput" />
<button type="button" @click="upload">Upload</button>
</form>
In your Vue method, remove the line event.preventDefault();
as it is not needed anymore.
async upload() {
//event.preventDefault();
}
Source:stackexchange.com