Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I download an image url from axios data response using VueJS

After I loop through the data in the front-end with Vue I am able to display the images but I do not know how to download it. I want to be able to click on either the image or a button in other to download the image.

<ul>
   <li v-for="data in mydata" :key="data.id">
      <img :src= "data.url" alt="image" class="img-thumbnail"/>
    </li>
</ul>
like image 413
Oluwagbemi Kadri Avatar asked Mar 07 '23 11:03

Oluwagbemi Kadri


1 Answers

You can use the download attribute of <a> element:

<li v-for="data in mydata" :key="data.id">
  <a :href="data.url" download>
    <img :src="data.url" alt="image" class="img-thumbnail"/>
  </a>
</li>

But note that IE and Safari don't support download
https://caniuse.com/#feat=download

like image 179
CodinCat Avatar answered Apr 26 '23 00:04

CodinCat