Once you need to switch routes in the Vue project, you should immediately think of several problems

foreword

This is the 11th blog of the Vue actual combat project. In the previous section, we newly defined some routing data , developed the left menu function through el-menu , and then developed the tg-menu component by ourselves. The template architecture is set up. This section mainly talks about a key point in the actual combat of a project, that is, when switching routes , you need to think of several problems immediately.

We are more accustomed to developing single-page applications with Vue, which means that all the pages we see are actually an HTML landing page. Through the main file main.js and the main entry component app.vue , plus vue-router , etc., all content combine. So, in fact, the whole project is a big Vue component, like a big tree, app.vue is the trunk, and there are many small components. Even if the route is switched and the content seen is different, the overall component is still this big Vue component.

Therefore, when switching routes, although some page content is invisible, its component may define some global variables or functions, which are still in memory. , what are the

Guess you like

Origin blog.csdn.net/xingyu_qie/article/details/130232249