Instance Properties
$data
Type:
Object-
Details:
The data object that the component instance is observing. The component instance proxies access to the properties on its data object.
See also: Options / Data - data
$props
Type:
Object-
Details:
An object representing the current props a component has received. The component instance proxies access to the properties on its props object.
$el
Type:
anyRead only
-
Details:
The root DOM element that the component instance is managing.
For components using fragments,
$elwill be the placeholder DOM node that Vue uses to keep track of the component's position in the DOM. It is recommended to use template refs for direct access to DOM elements instead of relying on$el.
$options
Type:
ObjectRead only
-
Details:
The instantiation options used for the current component instance. This is useful when you want to include custom properties in the options:
const app = createApp({ customOption: 'foo', created() { console.log(this.$options.customOption) // => 'foo' } })
$parent
Type:
Component instanceRead only
-
Details:
The parent instance, if the current instance has one.
$root
Type:
Component instanceRead only
-
Details:
The root component 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. Each named slot has its own corresponding property (e.g. the contents of
v-slot:foowill be found atthis.$slots.foo()). Thedefaultproperty contains either nodes not included in a named slot or contents ofv-slot:default.Accessing
this.$slotsis most useful when writing a component with a render function. -
Example:
<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 $slots.default. </p> </template> <template v-slot:footer> <p>Copyright 2020 Evan You</p> </template> </blog-post>const { createApp, h } = Vue const app = createApp({}) app.component('blog-post', { render() { return h('div', [ h('header', this.$slots.header()), h('main', this.$slots.default()), h('footer', this.$slots.footer()) ]) } }) -
See also:
$refs
Type:
ObjectRead only
Details:
An object of DOM elements and component instances, registered with ref attributes.
- See also:
$attrs
Type:
ObjectRead only
Details:
Contains parent-scope attribute bindings and events that are not recognized (and extracted) as component props or custom events. 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.
© 2013–present Yuxi Evan You
Licensed under the MIT License.
https://v3.vuejs.org/api/instance-properties.html