javascript - How vue components introduce external js
伊谢尔伦2017-06-05 11:12:49
0
3
640
I want to introduce an external swiper.js into a single-page component. I don’t want to install dependencies. I want to import js directly. Is there a way to achieve this? I have tried both import and require but it seems to have failed.
require / exports is CommonJS (implemented in Node), import / export is a module of ES2015, using vue will inevitably use webpack, webpack 1 supports CommonJS by default, and you only need to use babel for ES2015. https://www.zhihu.com/question/56820346/answer/150743994
So if you want to use this modular import syntax, the premise is that the library you reference is modular and the syntax is CommonJS. If you just want to import it, just add the
Just import it directly under index.html through
Introduce the js file you need to load in the index.html page
So if you want to use this modular import syntax, the premise is that the library you reference is modular and the syntax is CommonJS.
If you just want to import it, just add the