Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda