Collection of front-end interview skills Part 12: High-frequency test points (Vue often tests basic knowledge points)

This is for the record 前端面试的话术集锦第十二篇博文——高频考点(Vue常考基础知识点)and I will keep updating this blog post. ❗❗❗

In this chapter we will learn Vuesome basic knowledge points that are often tested in the future.

1. Life cycle hook function

  1. When beforeCreatethe hook function is called, the data in propsor cannot be obtained, because the initialization of these data is in.datainitState

  2. Then createdthe hook function will be executed. At this step, the data that was previously inaccessible can already be accessed, but the component has not been mounted yet, so it cannot be seen.

  3. Then beforeMountthe hook function will be executed first, the creation will start VDOM, and finally mountedthe hook will be executed, and VDOMthe rendering will be real DOMand the data will be rendered. If there are subcomponents in the component, the subcomponents will be mounted recursively. Only when all subcomponents are mounted, the mounting hook of the root component will be executed.

  4. beforeUpdateThen there are the hook functions and hook functions that will be called when the data is updated updated. There is nothing much to say about these two hook functions, they are called before and after the data is updated respectively.

  5. In addition, there are keep-aliveunique life cycles, respectively activatedand deactivated. Wrapped keep-alivecomponents will not be destroyed when switching, but cached in memory and executeddeactivated

Guess you like

Origin blog.csdn.net/lvoelife/article/details/132696339