Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
Use imported script inside development build of Vue

I'm currently building an application and, and I applied vue 3 only in one page via script.

<script src="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js"></script>
<script src="https://unpkg.com/vue@3"></script>

I'm trying to use the imported module (jsPdf) via a script, and it is not working.

methods: {
  generateReport() {
    let pdfName = 'test'; 
    var doc = new jsPDF();
    doc.text("Hello World", 10, 10);
    doc.save(pdfName + '.pdf');
  }
}

This is the error when I'm trying to do the method above:

Uncaught ReferenceError: jsPDF is not defined

Is it possible to use the module imported using script in the development build of Vue? or is there any other way to generate pdf without importing scripts?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try like following snippet

const { jsPDF } = jspdf
const app = Vue.createApp({
  el: "#demo",
  methods: {
    generateReport() {
      let pdfName = 'test'; 
      var doc = new jsPDF();
      doc.text("Hello World", 10, 10);
      doc.save(pdfName + '.pdf');
      console.log(doc)
    }
  }
})
app.mount('#demo')
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js"></script>
<script src="https://unpkg.com/vue@3"></script>
<div id="demo">
  <button @click="generateReport">pdf</button>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

Have you imported the library in the .vue file you are trying to use it in?
import { jsPDF } from "jspdf";

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!