20180828 content add:
my code directory structure is like this
-src
--conponents_mobile
---bb.vue
--conponents_pc
---bb.vue
then use routing to determine whether to move or pc to enter, using components in different folders, is it possible that two files with the same name in two component folders will appear to be loaded twice?
<template>
<div class="a">
<bb v-show="registerComponentShow"></bb>
<cc v-show="projectComponentShow"></cc>
</div>
</template>
as in the above structure, the mounted life cycle in one of my components, bb, has been called twice, and I wonder if it is because this component has been rendered twice?
then I changed it to the following
<template>
<div class="a">
<bb v-if="registerComponentShow"></bb>
<cc v-if="projectComponentShow"></cc>
</div>
</template>
so that the mounted in bb will not be called twice.
my problem is that for a component, if you add v-show to it, it renders < bb > < / bb > for the first time and then determines whether v-show is true, or not, so it looks like mounted has been executed twice.
look forward to your advice, thank you.
2018.9.21
just remembered that I should talk about the follow-up. In fact, I made it clear a few weeks ago. In fact, the problem is that the components are applied and the components are loaded directly, so I can see that they have been executed twice.
Optimization method: lazy load is used now, and load only when needed. You can use v-if or route control to redirect, and just configure webpack.