{ src: ‘/assets/js/bootstrap.js’, body: true }, In the README they say i've to pass the module to vue-loader in my webpack config. Usually, we put the list of what to import in curly braces import {…}. rev 2021.5.17.39323. Do you really need to inject an external script in the Vue component, will be discussed later, but we are here today for one reason – to find out how to load an external script in Vue.js. And if you don't setup your build tool correctly you may end up with … In some cases, you might want to include additional JavaScript script into your Vue app. I used this CSS file only as an example. To follow along in this tutorial you’ll need: 1. script2.js. export const countryCodes = { return [ 'DE', 'EN' ]; } javascript vue-component vue.js. Even though this is a CSS file, the same works with the script – just make sure you are adding this inside the btw, if you want to use reusable functionalities or data for your component, i recommend to use Mixins — Vue.js Yet the resource might not be used by the whole page (might be that only a specific function of the page uses it). To learn more, see our tips on writing great answers. To do that, we import it in the main.js file. How do I include a JavaScript file in another JavaScript file? And this error is pretty self-describing – templates are not intended for including scripts. So, let's say that I'm using axios module and extending it as a plugin. Using vue and creating amazing applications is simple and powerful. import { Name, Address, Age} from './script1.js'; let val = Name("John"); let age = Age(26); console.log(val + " and " + age); In script1.js, we have three modules named Name, Address, and Age. So when you install an npm package with Vue CLI, or Vue UI if you want to use it, the only thing you need to add something similar like this inside the