I'm trying to open a PDF file using VueJS. I want to open it in a new tab using the default navigator's player.
I've tried the following :
1
<a href="./pdf/doc.pdf" target="_blank">pdf</a>
Where /pdf/doc.pdf is located inside the public directory. That solution try to open a route adding /pdf/doc.pdf. Not expected and cannot visualize the PDF doc.
2
<a href="<%= BASE_URL %>/pdf/doc.pdf" target="_blank">pdf</a>
I got this error :
URIError: Failed to decode param '/fr/%3C%=%20BASE_URL%20%%3E/pdf/doc.pdf'
3
<a @click.prevent="pdfDoc">pdf</a>
data() {
return {
pdfDoc: require('../../public/pdf/doc.pdf')
}
}
I got this error :
./public/pdf/doc.pdf 1:0 Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
How can I simply implement a to open a PDF in a new tab and display it ?