'How to add a link to download a pdf file nuxt?
I just wants to add a link to download a pdf file in nuxt project.
How do I do that?
I have tried the following:
<a :href="require('@/static/documents/WTSDL2019_Pamplet.pdf')" download class="btn btn-sm btn-sub-color" >Download</a>
which works well for images but not for pdf files. I found vue-pdf but I feel its an extra work for the purpose of just linking a pdf file. I have no work view a pdf files with all those events.
Solution 1:[1]
This works:
<a href="/cv.pdf">Download my CV</a>
if you put the PDF in the static folder. You don't need the /static/ as NUXT does the magic.
Solution 2:[2]
<a :href="require('../assets/documents/WTSDL2019_Pamplet.pdf')" download>
Download
</a>
Solution 3:[3]
In my scenario, when I put file (1111.pdf) in sub-folder of static; like this static/pdf/1111.pdf , It doesn't response anything. But when I change to this 1111.pdf file to just under static folder, It works. This is my code:
<a href="../../1111.pdf" download="" target="_blank" >Download</a>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gabriel |
| Solution 2 | Ibrahim Mohammed |
| Solution 3 | Aung Myo Khant |
