This is for the record 前端面试的话术集锦第十二篇博文——高频考点(Vue常考基础知识点)
and I will keep updating this blog post. ❗❗❗
In this chapter we will learn Vue
some basic knowledge points that are often tested in the future.
1. Life cycle hook function
-
When
beforeCreate
the hook function is called, the data inprops
or cannot be obtained, because the initialization of these data is in.data
initState
-
Then
created
the 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. -
Then
beforeMount
the hook function will be executed first, the creation will startVDOM
, and finallymounted
the hook will be executed, andVDOM
the rendering will be realDOM
and 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. -
beforeUpdate
Then there are the hook functions and hook functions that will be called when the data is updatedupdated
. There is nothing much to say about these two hook functions, they are called before and after the data is updated respectively. -
In addition, there are
keep-alive
unique life cycles, respectivelyactivated
anddeactivated
. Wrappedkeep-alive
components will not be destroyed when switching, but cached in memory and executeddeactivated