Why do subcomponents not need import vue? when using vue

Why do subcomponents not need import vue? when using vue

Apr.05,2021

if you are based on vue-cli,webpack engineering development, using the kind of .vue file suffix for the file, this mode, there will be a vue-loader , the JavaScript code in your vue file is extracted, vue is already in these extracted code, you do not need to manually import vue , it is all thanks to vue-loader .


introduced


vue in webpack to match


since it is a sub-component, it means that the root component has introduced vue;
you try to comment out the import vue of the root component and see if it still works?
Vue-loader just precompiles the components into render function code;
if you write vue directly without vue-cli, you will understand.
as to why subcomponents don't reference vue, my answer is that the root component is already referenced.

Menu