Skip to content

Instance Properties API reference #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb63bde
feat: started with Global Config API
NataliaTepluhina Apr 19, 2020
af57779
feat: finished global config
NataliaTepluhina Apr 19, 2020
541ca7b
feat: added component global api
NataliaTepluhina Apr 25, 2020
e443c43
feat: added directives API
NataliaTepluhina Apr 25, 2020
7cd0651
feat: added mixin API
NataliaTepluhina Apr 25, 2020
5d9ee8c
feat: add mount API
NataliaTepluhina Apr 25, 2020
d55decb
feat: added unmount and use
NataliaTepluhina Apr 25, 2020
a98d5e2
Merge branch 'master' into api-reference
NataliaTepluhina Apr 25, 2020
e64ebf0
Update src/api/global-api.md
NataliaTepluhina Apr 26, 2020
49ffe23
Update src/api/global-config.md
NataliaTepluhina Apr 26, 2020
c4f9dd5
fixL changed global -> application
NataliaTepluhina Apr 26, 2020
ade37d0
Merge branch 'api-reference' of github.com:vuejs/docs-next into api-r…
NataliaTepluhina Apr 26, 2020
828972c
fix: fixed types for config
NataliaTepluhina Apr 26, 2020
1887ca5
fix: fixed types for API
NataliaTepluhina Apr 26, 2020
dfa977f
feat: added a note about native HTML tags
NataliaTepluhina Apr 26, 2020
cb6eb44
feat: added options data chapter
NataliaTepluhina Apr 26, 2020
aef68b0
feat: finished options data
NataliaTepluhina Apr 26, 2020
aeefc99
Merge branch 'master' into options-api
NataliaTepluhina Apr 30, 2020
d3d0d25
feat: added options-DOM
NataliaTepluhina Apr 30, 2020
98572f9
Added emits to data
NataliaTepluhina May 1, 2020
a69868d
feat: added lifecycle hooks
NataliaTepluhina May 1, 2020
050fae0
feat: added renderTracked and renderTriggered
NataliaTepluhina May 2, 2020
7bd1d81
feat: added options assets
NataliaTepluhina May 2, 2020
20b9627
feat: added options composition
NataliaTepluhina May 2, 2020
4a2f1e4
feat: added misc to options
NataliaTepluhina May 2, 2020
a800329
fix: TODO cleanup
NataliaTepluhina May 2, 2020
3b72dec
fix: changed data description
NataliaTepluhina May 3, 2020
b7f4d25
Added instance properties
NataliaTepluhina May 3, 2020
b62c049
Squashed commit of the following:
NataliaTepluhina May 4, 2020
34996ad
Revert "Squashed commit of the following:"
NataliaTepluhina May 4, 2020
962d7f4
Merge branch 'master' into instance-properties-api
NataliaTepluhina May 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const sidebar = {
'/api/options-composition',
'/api/options-misc'
]
}
},
'/api/instance-properties.md'
]
}

Expand Down
146 changes: 146 additions & 0 deletions src/api/instance-properties.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Instance Properties

## $data

- **Type:** `Object`

- **Details:**

The data object that the Vue instance is observing. The Vue instance proxies access to the properties on its data object.

- **See also:** [Options / Data - data](./options-data.html#data-2)

## $props

- **Type:** `Object`

- **Details:**

An object representing the current props a component has received. The Vue instance proxies access to the properties on its props object.

## $el

- **Type:** `any`

- **Read only**

- **Details:**

The root DOM element that the Vue instance is managing.

## $options

- **Type:** `Object`

- **Read only**

- **Details:**

The instantiation options used for the current Vue instance. This is useful when you want to include custom properties in the options:

```js
const app = Vue.createApp({
customOption: 'foo',
created() {
console.log(this.$options.customOption) // => 'foo'
}
})
```

## $parent

- **Type:** `Vue instance`

- **Read only**

- **Details:**

The parent instance, if the current instance has one.

## $root

- **Type:** `Vue instance`

- **Read only**

- **Details:**

The root Vue instance of the current component tree. If the current instance has no parents this value will be itself.

## $slots

- **Type:** `{ [name: string]: (...args: any[]) => Array<VNode> | undefined }`

- **Read only**

- **Details:**

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`.

Accessing `vm.$slots` is most useful when writing a component with a [render function](TODO).

- **Example:**

```html
<blog-post>
<template v-slot:header>
<h1>About Me</h1>
</template>

<template v-slot:default>
<p>
Here's some page content, which will be included in vm.$slots.default.
</p>
</template>

<template v-slot:footer>
<p>Copyright 2020 Evan You</p>
</template>
</blog-post>
```

```js
const app = Vue.createApp({})

app.component('blog-post', {
render() {
return Vue.h('div', [
Vue.h('header', this.$slots.header()),
Vue.h('main', this.$slots.default()),
Vue.h('footer', this.$slots.footer())
])
}
})
```

- **See also:**
- [`<slot>` Component](TODO)
- [Content Distribution with Slots](../guide/component-basics.html#content-distribution-with-slots)
- [Render Functions - Slots](TODO)

## $refs

- **Type:** `Object`

- **Read only**

- **Details:**

An object of DOM elements and component instances, registered with [`ref` attributes](TODO).

- **See also:**
- [Child Component Refs](TODO:refs)
- [Special Attributes - ref](TODO)

## $attrs

- **Type:** `Object`

- **Read only**

- **Details:**

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.

- **See also:**
- [Non-Prop Attributes](../guide/component-props.html#non-prop-attributes)