You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Restriction:**only respected in instance creation via `new`.
527
+
-**限制:**只在由 `new` 创建的实例中遵守。
528
528
529
-
-**Details:**
529
+
-**详细:**
530
530
531
-
Provide the Vue instance an existing DOM element to mount on. It can be a CSS selector string or an actual HTMLElement.
531
+
为实例提供挂载元素。值可以是 CSS 选择符,或实际 HTML 元素。
532
532
533
-
After the instance is mounted, the resolved element will be accessible as `vm.$el`.
533
+
在实例挂载之后, 元素可以用 `vm.$el` 访问。
534
534
535
-
If this option is available at instantiation, the instance will immediately enter compilation; otherwise, the user will have to explicitly call `vm.$mount()`to manually start the compilation.
<pclass="tip">The provided element merely serves as a mounting point. Unlike in Vue 1.x, the mounted element will be replaced with Vue-generated DOM in all cases. It is therefore not recommended to mount the root instance to `<html>` or `<body>`.</p>
A string template to be used as the markup for the Vue instance. The template will **replace**the mounted element. Any existing markup inside the mounted element will be ignored, unless content distribution slots are present in the template.
If the string starts with `#`it will be used as a querySelector and use the selected element's innerHTML as the template string. This allows the use of the common `<script type="x-template">`trick to include templates.
<pclass="tip">From a security perspective, you should only use Vue templates that you can trust. Never use user-generated content as your template.</p>
An alternative to string templates allowing you to leverage the full programmatic power of JavaScript. The render function receives a `createElement`method as it's first argument used to create `VNode`s.
If the component is a functional component, the render function also receives an extra argument `context`, which provides access to contextual data since functional components are instance-less.
All lifecycle hooks automatically have their `this`context bound to the instance, so that you can access data, computed properties, and methods. This means __you should not use an arrow function to define a lifecycle method__ (e.g.`created: () => this.fetchTodos()`). The reason is arrow functions bind the parent context, so `this`will not be the Vue instance as you expect and `this.fetchTodos`will be undefined.
Called synchronously after the instance is created. At this stage, the instance has finished processing the options which means the following have been set up: data observation, computed properties, methods, watch/event callbacks. However, the mounting phase has not been started, and the `$el`property will not be available yet.
Called after the instance has just been mounted where `el`is replaced by the newly created `vm.$el`. If the root instance is mounted to an in-document element, `vm.$el`will also be in-document when `mounted` is called.
Called after a data change causes the virtual DOM to be re-rendered and patched.
638
+
由于数据更改导致的虚拟 DOM 重新渲染和打补丁,在这之后会调用该钩子。
639
639
640
-
The component's DOM will be in updated state when this hook is called, so you can perform DOM-dependent operations in this hook. However, in most cases you should avoid changing state in this hook, because it may lead to an infinite update loop.
640
+
当这个钩子被调用时,组件 DOM 已经更新,所以你现在可以执行依赖于 DOM 的操作。然而在大多数情况下,你应该避免在此期间更改状态,因为这可能会导致更新无限循环。
641
641
642
-
**This hook is not called during server-side rendering.**
Called after a Vue instance has been destroyed. When this hook is called, all directives of the Vue instance have been unbound, all event listeners have been removed, and all child Vue instances have also been destroyed.
0 commit comments