Hey I am really new to Vue and for this project I have a DOWNLOAD BUTTON from where the users can download a file. When I click on the DOWNLOAD BUTTON it keeps on opening the file in the same browser rather downloading it. Is their a way to make a-href
or button function
to download the file?
My code on jsFiddle https://jsfiddle.net/ez36jmx5/10/ .
View
<div id="app">
<a href="https://homepages.cae.wisc.edu/~ece533/images/airplane.png" download>DOWNLOAD</a>
<br><br>
<button v-on:click="clickedDownload()"> <!-- opens files in new tab -->
DOWNLOAD
</button>
</div>
Method
new Vue({
el: "#app",
data: {
},
methods: {
clickedDownload(){
var fileName='https://homepages.cae.wisc.edu/~ece533/images/airplane.png';
window.open(fileName, 'Download');
}
}
})