[Vuejs]-Open a PDF using VueJS

1👍

Assuming your directory is like:

src -> assets --> Resume.pdf

You can access it by:

<input type="button" value="Open" onClick="readFile()");


methods: {
  readFile() {
     window.open('src/assets/Resume.pdf', '_blank') //to open in new tab
   }
}
👤DjSh

0👍

Using click event, window.open() and require.

<span @click="handleClick">a pdf file</span>
handleClick: () => {
  window.open(require('/path/to/my/pdf.pdf'), '_blank')
}
👤tat757

-2👍

In VueJS, there’s a folder called “static” or “statics” and all you have to do is move the file to “statics” to be able to access it through local directory.

Leave a comment