Answer the question
In order to leave comments, you need to log in
How to make a dynamic library import inside a method in vue?
At the front, I want to load the PDF generation library only by pressing the "generate PDF" button - download the library and start the generation.
Google dynamic import of components, but not libraries.
Is it possible to do something like this inside a vue method:
methods: {
generatePDF() {
const html2pdfd = () => import ("html2pdf" /*webpackChunkName:"html2Pdf"*/)
html2pdfd()
},
...
}
Answer the question
In order to leave comments, you need to log in
Maybe. You yourself wrote how. Further, the usual asynchrony has nothing to do with Vue or collectors.
methods: {
async generatePDF() {
const html2pdfd = await import("html2pdf" /*webpackChunkName:"html2Pdf"*/);
html2pdfd()
},
...
}
methods: {
generatePDF() {
import("html2pdf" /*webpackChunkName:"html2Pdf"*/).than(html2pdfd => {
html2pdfd()
})
},
...
}
The person went to the page, so he needs it. And the component can beat on pages. What is the problem?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question