title: How to show pdf with iframe in vue.js
body: <p>I have a vue.js webapp, I want to show an PDF in an iframe in the app, but it is not taking the path from the <code>assets</code> folder. Here is my code:</p>
  
  <pre><code>&lt;iframe :src="getPDFPath()" style="width: 100vw;height: 100%;border: none;"&gt;
    Oops! an error has occurred.
  &lt;/iframe&gt;
  </code></pre>
  
  <p>Here is the <code>getPDFPath</code> method:</p>
  
  <pre><code>getPDFPath () {
     return '../../assets/my.pdf'
  }
  </code></pre>
  
  <p>But this did not work and gives following error:</p>
  
  <blockquote>
    <p>Cannot GET /assets/my.pdf</p>
  </blockquote>
  
  <p>However result of <code>{{ getPDFPath() }}</code> is : <code>../../assets/my.pdf</code>.</p>
  
  <p>As I am using webpack, I also tried following, which also did not work:</p>
  
  <pre><code>getPDFPath () {
    var files = require.context('../../assets/', false)
    return files('./my.pdf')
  }
  </code></pre>
  
  <p>This gives me following error:</p>
  
  <blockquote>
    <p>./src/assets/my.pdf</p>
    
    <p>Module parse failed: >/Users/abc/work/codes/vue/src/assets/my.pdf 
    Unexpected token (1:0)</p>
    
    <p>You may need an appropriate loader to handle this file type.</p>
  </blockquote>
  
  <p>However above code works for images, as I have earlier answered <a href="https://stackoverflow.com/a/40493036/1610034">here</a>.</p>