How do vue single-file components use other frameworks or libraries?

create projects using vue-cli3.x scaffolding
how can I use other UI frameworks or libraries in single-file vue components?
such as jQuery, Layui, Bootstrap.

I try to add a resource reference directly to public/index.html , add the road strength prefix
, and then bind the global variable to Vue.prototype in main.js and then use it in the vue single file component. Although it works, this should not be the correct way to use
and will report an error and warning every time it is compiled

.

look for other uses and find that they are all vue-cli2.x versions, which are realized by modifying the webpack configuration. The
vue-cli3.x version of the document is not understood, ask for boss"s help!


install the ui or js library you need through npm install xxx, introduce it in main.js, mount it to the instance of vue, and then use the plug-in or library you introduce globally
clipboard.png
. To use the ui library, you need to import a separate css file, and this css file is in the library you installed


.

using the external framework according to the principle, it is normal to bring in the corresponding css,js,html resources and initialize normally within the component.

however, depending on the project, some designs need to use these external resources globally, so they will put them on the prototype of vue.

if you have to do this, you can actually use use, that is, the use of the vue plug-in

.

learn how to use use

Menu