components
option of the parent component. Custom components declared like this can be used just like built-in components.Vue.component()
in the main script of the application:props
section specifies that this component has two properties, okText
and cancelText
, and their values must be strings. You can use other JavaScript types, like Boolean
, Numeric
, Array
or Object
to validate the property.v-bind
:v-bind
directive even if you pass a constant value. Otherwise the value would be interpreted as a string. For example:true
to a boolean property:v-on
directive:value
property, because that will not automatically update the data in the parent component.v-model
directive can also be used with custom components. By default, it binds the value
property and the input
event to the specified property of the parent component, so the above code is equivalent to:<slot>
element. The slot contents can include not just text, but also other elements, including built-in components and custom components.<component>
element can be used to dynamically switch between components. For example, you can replace the entire contents of a window without having to close it and create a new window:currentComponent
property can contain either the name of a registered component, or the options object which defines a component.