0

What is the correct way of importing javascript modules into vue-components?

I currently have a vue-component component.js:

Vue.component('component', {
    name: 'component',
    props: ['pdf'],
    template: ` ...

I want to take a pdf-url as a prop and use pdf.js within the component, but I'm having trouble finding the right way/standard way to import pdf.js into my project.

Worth noting is that I'm not using vue-cli, or any other kind of bundler like Webpack, so my project structure might be a bit different from standard project structures. I access my components from a main.html file in which I have imported both vue and the components in script-tags in the head of the html. Would I simply import pdf.js in the same manner (head in the main.html file), or is there a "vue"-way of doing it?

1
  • 1
    "is there a "vue"-way of doing it?" <- one of the best things about Vue is that it is un-opinionated about any other library you want to use Commented Aug 15, 2018 at 8:27

1 Answer 1

2

If you are not using webpack or any other packager, then I will recommend you to stick to the old fashion way, just use pdf.js as script in your html and make use of the API as it is in the official documentation, such as: pdf.getPage(1).then(...)

Hope it helps.

Cheers

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.