Skip to content

Commit a56d0eb

Browse files
committed
add instance lifecycle methods to API docs
1 parent 7f992a1 commit a56d0eb

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/api/index.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,3 +761,62 @@ type: api
761761
- [Vue.nextTick](#Vue-nextTick)
762762
-!!TODO: [Async Update Queue](/guide/reactivity.html#Async-Update-Queue)
763763

764+
## Instance Methods / Lifecycle
765+
766+
<h3 id="vm-mount">vm.$mount( [elementOrSelector], [hydrating] )</h3>
767+
768+
- **Arguments:**
769+
- `{Element | String} [elementOrSelector]`
770+
- `{Boolean} [hydrating]`
771+
772+
- **Returns:** `vm` - the instance itself
773+
774+
- **Usage:**
775+
776+
If a Vue instance didn't receive the `el` option at instantiation, it will be in "unmounted" state, without an associated DOM element. `vm.$mount()` can be used to manually start the mounting/compilation of an unmounted Vue instance.
777+
778+
If `elementOrSelector` argument is not provided, the element is managed in Vue instance will be created as an out-of-document DOM element, and you will have to use DOM API to insert it into the document yourself.
779+
780+
If `hydrating` argument is provided as `true`, in the rendering process of this method, run the DOM elements hydration.
781+
782+
The method returns the instance itself so you can chain other instance methods after it.
783+
784+
- **Example:**
785+
786+
``` js
787+
var MyComponent = Vue.extend({
788+
template: '<div>Hello!</div>'
789+
})
790+
791+
// create and mount to #app (will replace #app)
792+
new MyComponent().$mount('#app')
793+
794+
// the above is the same as:
795+
new MyComponent({ el: '#app' })
796+
797+
// or, compile off-document and append afterwards:
798+
var component = new MyComponent().$mount()
799+
document.getElementById('app').appendChild(vm.$el)
800+
```
801+
802+
- **See also:**
803+
- [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
804+
- !!TODO: [Server-Side Rendering](/guide/ssr.html)
805+
806+
<h3 id="vm-forceUpdate">vm.$forceUpdate( )</h3>
807+
808+
- **Usage:**
809+
810+
The Vue instance will be forced into a “digest cycle”, during which all its watchers are re-evaluated.
811+
812+
<p class="tip">Note: This method have an influence on your application performance degradation. The excessive call is no recommended.</p>
813+
814+
<h3 id="vm-destroy">vm.$destroy( )</h3>
815+
816+
- **Usage:**
817+
818+
Completely destroy a vm. Clean up its connections with other existing vms, unbind all its directives, turn off all event listeners.
819+
820+
Triggers the `beforeDestroy` and `destroyed` hooks.
821+
822+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)

0 commit comments

Comments
 (0)