I have an app which uses vue and laravel with laravel mix, I installed a js library called ProgressBar.js via npm install, however now I don't know how to use that library in my .vue files, how can I use the library inside my single file components, maybe adding it to the vue prototype, but how can I require it now?
1 Answer
If you started your Vue app with vue create command, you can simply import it in your App.vue. Example:
<script>
import ProgressBar from 'progressbar.js'
export default {
mounted() {
const line = new ProgressBar.Line('#container')
}
}
</scirpt>
3 Comments
gabogabans
I actually do something like this: const app = new Vue({ el: '#vueapp', store,
Nikolay Yankov
Is it just in plain html file your new Vue instance?
Nikolay Yankov
If it's simply an HTML file, then you have add a
<script> tag with src to node_modules/progressbar.js/dist/progressbar.js and then use it directly from window in your Vue instance. window.Progressbar