简体   繁体   English

如何在 vuejs 中下载文件?

[英]how to download files in vuejs?

I am trying to download a file in my website.我正在尝试在我的网站上下载文件。 item.upload_attachment contain the link of the download link url eg localhost:8000/media/uploads/poppy.docx . item.upload_attachment包含下载链接 url 例如localhost:8000/media/uploads/poppy.docx的链接。 But i want the link to be clickable so that the user can download it.但我希望链接是可点击的,以便用户可以下载它。 Is it possible to put it in a <a></a> tags?是否可以将其放在<a></a>标签中?

index.vue

<template v-slot:item.upload_attachment="{ item }">
     <span>
       {{ item.upload_attachment}}
     </span>
</template>

The solution for this question:这个问题的解决方案:


<template v-slot:item.upload_attachment="{ item }">
                 <span>
                    <a :href=item.upload_attachment> Download</a>
                </span>
              </template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM