pdfvue.jsnuxt.js

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

  • I had the same problem, and this worked for me. I added the file to the public folder (static in Nuxt 2) and it worked.

    <a href="/WTSDL2019_Pamplet.pdf" download="">Download</a>