Skip to content

Commit 3e36371

Browse files
Instance Properties API reference (#75)
* feat: started with Global Config API * feat: finished global config * feat: added component global api * feat: added directives API * feat: added mixin API * feat: add mount API * feat: added unmount and use * Update src/api/global-api.md Co-Authored-By: Jinjiang <zhaojinjiang@me.com> * Update src/api/global-config.md Co-Authored-By: Jinjiang <zhaojinjiang@me.com> * fixL changed global -> application * fix: fixed types for config * fix: fixed types for API * feat: added a note about native HTML tags * feat: added options data chapter * feat: finished options data * feat: added options-DOM * Added emits to data * feat: added lifecycle hooks * feat: added renderTracked and renderTriggered * feat: added options assets * feat: added options composition * feat: added misc to options * fix: TODO cleanup * fix: changed data description * Added instance properties * Squashed commit of the following: commit 5509287 Author: Natalia Tepluhina <tarya.se@gmail.com> Date: Mon May 4 06:57:13 2020 +0300 Options API Reference (#73) * feat: started with Global Config API * feat: finished global config * feat: added component global api * feat: added directives API * feat: added mixin API * feat: add mount API * feat: added unmount and use * Update src/api/global-api.md Co-Authored-By: Jinjiang <zhaojinjiang@me.com> * Update src/api/global-config.md Co-Authored-By: Jinjiang <zhaojinjiang@me.com> * fixL changed global -> application * fix: fixed types for config * fix: fixed types for API * feat: added a note about native HTML tags * feat: added options data chapter * feat: finished options data * feat: added options-DOM * Added emits to data * feat: added lifecycle hooks * feat: added renderTracked and renderTriggered * feat: added options assets * feat: added options composition * feat: added misc to options * fix: TODO cleanup * fix: changed data description Co-authored-by: Jinjiang <zhaojinjiang@me.com> commit b31cbfc Author: Damian Dulisz <damian.dulisz@gmail.com> Date: Sun May 3 16:18:35 2020 +0200 [Rough Draft] Composition-API: Introduction (#67) * Add Composition-API: Introduction draft * Fix image links * Add styling for Tips and Warnings. Fix missing `js` syntax flag * Apply suggestions from An Phan Co-Authored-By: Phan An <me@phanan.net> * Apply suggestions from code review Co-Authored-By: Phan An <me@phanan.net> Co-Authored-By: Rahul Kadyan <hi@znck.me> * Convert tabs to spaces Co-authored-by: Phan An <me@phanan.net> Co-authored-by: Rahul Kadyan <hi@znck.me> commit 19c7285 Author: NataliaTepluhina <tarya.se@gmail.com> Date: Sun May 3 17:18:17 2020 +0300 fix: fixed slots inconsistence * Revert "Squashed commit of the following:" This reverts commit b62c049. Co-authored-by: Jinjiang <zhaojinjiang@me.com>
1 parent 5509287 commit 3e36371

File tree

2 files changed

+148
-1
lines changed

2 files changed

+148
-1
lines changed

src/.vuepress/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const sidebar = {
6868
'/api/options-composition',
6969
'/api/options-misc'
7070
]
71-
}
71+
},
72+
'/api/instance-properties.md'
7273
]
7374
}
7475

src/api/instance-properties.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Instance Properties
2+
3+
## $data
4+
5+
- **Type:** `Object`
6+
7+
- **Details:**
8+
9+
The data object that the Vue instance is observing. The Vue instance proxies access to the properties on its data object.
10+
11+
- **See also:** [Options / Data - data](./options-data.html#data-2)
12+
13+
## $props
14+
15+
- **Type:** `Object`
16+
17+
- **Details:**
18+
19+
An object representing the current props a component has received. The Vue instance proxies access to the properties on its props object.
20+
21+
## $el
22+
23+
- **Type:** `any`
24+
25+
- **Read only**
26+
27+
- **Details:**
28+
29+
The root DOM element that the Vue instance is managing.
30+
31+
## $options
32+
33+
- **Type:** `Object`
34+
35+
- **Read only**
36+
37+
- **Details:**
38+
39+
The instantiation options used for the current Vue instance. This is useful when you want to include custom properties in the options:
40+
41+
```js
42+
const app = Vue.createApp({
43+
customOption: 'foo',
44+
created() {
45+
console.log(this.$options.customOption) // => 'foo'
46+
}
47+
})
48+
```
49+
50+
## $parent
51+
52+
- **Type:** `Vue instance`
53+
54+
- **Read only**
55+
56+
- **Details:**
57+
58+
The parent instance, if the current instance has one.
59+
60+
## $root
61+
62+
- **Type:** `Vue instance`
63+
64+
- **Read only**
65+
66+
- **Details:**
67+
68+
The root Vue instance of the current component tree. If the current instance has no parents this value will be itself.
69+
70+
## $slots
71+
72+
- **Type:** `{ [name: string]: (...args: any[]) => Array<VNode> | undefined }`
73+
74+
- **Read only**
75+
76+
- **Details:**
77+
78+
Used to programmatically access content [distributed by slots](../guide/component-basics.html#content-distribution-with-slots). Each [named slot](../guide/component-slots.html#named-slots) has its own corresponding property (e.g. the contents of `v-slot:foo` will be found at `vm.$slots.foo()`). The `default` property contains either nodes not included in a named slot or contents of `v-slot:default`.
79+
80+
Accessing `vm.$slots` is most useful when writing a component with a [render function](TODO).
81+
82+
- **Example:**
83+
84+
```html
85+
<blog-post>
86+
<template v-slot:header>
87+
<h1>About Me</h1>
88+
</template>
89+
90+
<template v-slot:default>
91+
<p>
92+
Here's some page content, which will be included in vm.$slots.default.
93+
</p>
94+
</template>
95+
96+
<template v-slot:footer>
97+
<p>Copyright 2020 Evan You</p>
98+
</template>
99+
</blog-post>
100+
```
101+
102+
```js
103+
const app = Vue.createApp({})
104+
105+
app.component('blog-post', {
106+
render() {
107+
return Vue.h('div', [
108+
Vue.h('header', this.$slots.header()),
109+
Vue.h('main', this.$slots.default()),
110+
Vue.h('footer', this.$slots.footer())
111+
])
112+
}
113+
})
114+
```
115+
116+
- **See also:**
117+
- [`<slot>` Component](TODO)
118+
- [Content Distribution with Slots](../guide/component-basics.html#content-distribution-with-slots)
119+
- [Render Functions - Slots](TODO)
120+
121+
## $refs
122+
123+
- **Type:** `Object`
124+
125+
- **Read only**
126+
127+
- **Details:**
128+
129+
An object of DOM elements and component instances, registered with [`ref` attributes](TODO).
130+
131+
- **See also:**
132+
- [Child Component Refs](TODO:refs)
133+
- [Special Attributes - ref](TODO)
134+
135+
## $attrs
136+
137+
- **Type:** `Object`
138+
139+
- **Read only**
140+
141+
- **Details:**
142+
143+
Contains parent-scope attribute bindings and events that are not recognized (and extracted) as component [props](./options-data.html#props) or [custom events](./options-data.html#emits). When a component doesn't have any declared props or custom events, this essentially contains all parent-scope bindings, and can be passed down to an inner component via `v-bind="$attrs"` - useful when creating higher-order components.
144+
145+
- **See also:**
146+
- [Non-Prop Attributes](../guide/component-props.html#non-prop-attributes)

0 commit comments

Comments
 (0)