VUE introduces external components, is it only useful for cli environment development?

introduce public components such as.. / lib/abc.vue

is it only available in the cli scaffolding development environment?
how to introduce external components into the development mode of non-cli, direct < script src= "vue.js"?

Sep.16,2021

you can see it by looking at the packaged file. In the end, what you print out is not a .vue file. Scaffolding is convenient for you to develop, so it is finally packaged into js, so vue.js can also be introduced into external components directly. You need to register the component according to the official website and write the component into the .js file.


component is simply an object. In cli, .vue is eventually compiled into the form of components, so if you want to use it directly in the browser, you need to get the compiled form


.vue single file component, direct < script src= "vue.js" development mode, need to write your own loader, is not recommended.
traditional mode, it is recommended to gulp+require+babel,define a global component, or component option, which is introduced by require. Gulp has a ready-made require merge / babel conversion plug-in, and it is easy to load on demand.
traditionally, if you do not even use require, the browser will increase the number of additional requests because a lot of js will be added to the component partition. If you want to optimize, you still need to write your own packaging tool, so it is not recommended.


.vue files need to be compiled before they can be used. If you want to introduce < script src= "vue.js" >, you need to compile the .vue files and register them in the corresponding place. This process is still troublesome

.
Menu