I have a single page application where I would like users to be able to download a locally stored pdf. However everything I try results in various errors.
Here is a link to a very similar problem... How to download a locally stored file in VueJS
However as I'm using vue cli 3, I do not have the webpack.config file and of course I'm trying to download a pdf, not a csv (hence why I can't use the solution to his question)
├──app │ └──Views │ └──page1.vue └──assets └──example.pdf In page1.vue I have this line:
<a v-bind:href="item.loc" download>{{item.title}}</a> And in the export I have this line
data() { return { item: {title: 'Download PDF', loc: require('../static/example.pdf')} } However this method returns this error...
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type. (Source code omitted for this binary file)
I can't seem to find a 'PDF Loader' unfortunately.