8000 update api overview · poorprogrammer/vuejs.org@52af374 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52af374

Browse files
committed
update api overview
1 parent 46e10a5 commit 52af374

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

source/api/index.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
title: "The Vue Constructor"
1+
title: Overview
22
type: api
33
order: 1
44
---
55

6+
## The Vue Constructor
7+
68
The `Vue` constructor is the core of Vue.js. It is a constructor function that allows you to create Vue instances. Creating a Vue instance is straightforward:
79

810
``` js
911
var vm = new Vue({ /* options */ })
1012
```
1113

12-
When you instantiate a Vue instance, you need to pass in an option object which can include information about the DOM element, data object, mixin methods, lifecycle callbacks and more. See the full list of [Instantiation Options](/api/options.html).
14+
When you instantiate a Vue instance, you need to pass in an option object which can include information about the DOM element, data object, mixin methods, lifecycle callbacks and more. See the full list of [Component Options](/api/options.html).
15+
16+
Each Vue instance is essentially a ViewModel (hence the variable name `vm` you will see throughout the docs). It has an associated DOM element `$el`, which is roughly the V in MVVM. It also has an associated JavaScript object `$data`, which corresponds to the M in MVVM. Changing the M results in updates in the V. For two-way bindings, user inputs triggered in the V results in changes in the M. For more details on what properties are available on a Vue instance, check out [Instance Properties](/api/instance-properties.html).
17+
18+
Each Vue instance also has a number of [Instance Methods](/api/instance-methods.html) which cover data observation, event communication and DOM manipulation.
1319

14-
Each Vue instance is essentially a ViewModel (hence the variable name `vm` you will see throughout the docs). It has an associated DOM element `$el`, which is roughly the V in MVVM. It also has an associated JavaScript object `$data`, which corresponds to the M in MVVM. Changing the M results in updates in the V. For two-way bindings, user inputs triggered in the V results in changes in the M. For more details check out [Instance Properties](/api/instance-properties.html).
20+
The `Vue` constructor itself also exposes the [Global API](/api/global-api.html), which allow you to extend the `Vue` class, configure global settings and register global custom assets such as components, directives, filters and more.
21+
22+
## Initialization
1523

1624
If you provided the `el` option at instantiation, the Vue instance will immediately enter the compilation phase. Otherwise, it will wait until `vm.$mount()` is called before it starts compilation. During the compilation phase, Vue walks through the DOM and collects the directives it runs into, and "links" the data and the DOM with these directives. Once linked, these DOM nodes are now said to be managed by the Vue instance. A DOM node can only be managed by one Vue instance, and should not be compiled more than once.
1725

26+
## Data Proxying
27+
1828
Vue instances proxy access to their `$data` objects, so if you have `vm.$data.msg` you can also access it as `vm.msg`. This might look a bit magical, but is totally optional. You can stick to `vm.$data.msg` for more explicit data access. However it is still important to notice the difference between `vm` and `vm.$data`, since the former cannot be observed by other Vue instances as data.
1929

2030
It's also worth noting that data objects do not necessarily belong to a single Vue instance - multiple ViewModels can observe the same piece of data, whether directly as `$data` or nested under it. This is useful when multiple components need to react to a shared global state object.
2131

22-
Each Vue instance also has a number of [Instance Methods](/api/instance-methods.html) which cover data observation, event communication and DOM manipulation.
32+
## Components
2333

24-
Finally, the `Vue` constructor itself also exposes the [Global API](/api/global-api.html), which allow you to extend the `Vue` class, configure global settings and register global custom assets such as components, directives, filters and more.
34+
When building complex UI, we often need to structure our app as a tree of components. Vue.js' component system allows you to do exactly that. The Vue constructor can be extended to define components that encapsulate its own template and data logic, and Vue provides a Web Component like syntax for you to compose your components in the template. For more details, read the [Component System](/guide/components.html) section of the guide.

source/api/options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
title: Options
1+
title: Component Options
22
type: api
33
order: 2
44
---

0 commit comments

Comments
 (0)
0