网页 综合 更新时间 2026-11-13 16:59:12

Options: Lifecycle | Vue.js

自动蜘蛛 vuejs.org 正文约 3225 字
Options: Lifecycle | Vue.js
Reactivity: Utilities
Reactivity: Advanced
Dependency Injection
Options: Composition
Syntax Specification
Server-Side Rendering
TypeScript Utility Types
For shared usage of lifecycle hooks, see Guide - Lifecycle Hooks
Called when the instance is initialized.
Called immediately when the instance is initialized and props are resolved.
Then the props will be defined as reactive properties and the state such as data() or computed will be set up.
Note that the setup() hook of Composition API is called before any Options API hooks, even beforeCreate().
Called after the instance has finished processing all state-related options.
When this hook is called, the following have been set up: reactive data, computed properties, methods, and watchers. However, the mounting phase has not been started, and the $el property will not be available yet.
Called right before the component is to be mounted.
When this hook is called, the component has finished setting up its reactive state, but no DOM nodes have been created yet. It is about to execute its DOM render effect for the first time.
This hook is not called during server-side rendering.
Called after the component has been mounted.
A component is considered mounted after:
All of its synchronous child components have been mounted (does not include async components or components inside <Suspense> trees).
Its own DOM tree has been created and inserted into the parent container. Note it only guarantees that the component's DOM tree is in-document if the application's root container is also in-document.
This hook is typically used for performing side effects that need access to the component's rendered DOM, or for limiting DOM-related code to the client in a server-rendered application.
This hook is not called during server-side rendering.
Called right before the component is about to update its DOM tree due to a reactive state change.
This hook can be used to access the DOM state before Vue updates the DOM. It is also safe to modify component state inside this hook.
This hook is not called during server-side rendering.
Called after the component has updated its DOM tree due to a reactive state change.
A parent component's updated hook is called after that of its child components.
This hook is called after any DOM update of the component, which can be caused by different state changes. If you need to access the updated DOM after a specific state change, use nextTick() instead.
This hook is not called during server-side rendering.
Do not mutate component state in the updated hook - this will likely lead to an infinite update loop!
Called right before a component instance is to be unmounted.
When this hook is called, the component instance is still fully functional.
This hook is not called during server-side rendering.
Called after the component has been unmounted.
A component is considered unmounted after:
All of its child components have been unmounted.
All of its associated reactive effects (render effect and computed / watchers created during setup()) have been stopped.
Use this hook to clean up manually created side effects such as timers, DOM event listeners or server connections.
This hook is not called during server-side rendering.
访问原文 返回搜索 https://vuejs.org/api/options-lifecycle
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。