So simple that most of us are convinced to fully understand how they work and how to use them. Optional - only needed if expecting props to be passed to the slot.Line-height and vertical-align are simple CSS properties. number - cast valid input string to numbersĭenote named slots or scoped slots that expect to receive props.Įxpects: JavaScript expression that is valid in a function argument position, including support for destructuring. lazy - listen to change events instead of input camel is not needed if you are using string templates, or pre-compiling the template with a build step.Ĭreate a two-way binding on a form input element or a component.Įxpects: varies based on value of form inputs element or output of components prop modifier also has a dedicated shorthand. When used without an argument, can be used to bind an object containing attribute name-value pairs. When used for component prop binding, the prop must be properly declared in the child component. This is sometimes necessary, especially when working with custom elements. This should work in most cases, but you can override this behavior by explicitly using. If the property is defined, Vue will set the value as a DOM property instead of an attribute. When setting a binding on an element, Vue by default checks whether the element has the key defined as a property using an in operator check. See linked guide section below for more details. When used to bind the class or style attribute, v-bind supports additional value types such as Array or Objects. attr - force a binding to be set as a DOM attribute. prop - force a binding to be set as a DOM property. camel - transform the kebab-case attribute name into camelCase. prop modifier)Įxpects: any (with argument) | Object (without argument) Listening to custom events on a child component (the handler is called when "my-event" is emitted on the child):ĭynamically bind one or more attributes, or a component prop to an expression. Note when using the object syntax, it does not support any modifiers. V-on also supports binding to an object of event / listener pairs without an argument. If using inline statement, the statement has access to the special $event property: v-on:click="handle('ok', $event)". When listening to native DOM events, the method receives the native event as the only argument. When used on a custom element component, it listens to custom events emitted on that child component. When used on a normal element, it listens to native DOM events only. The expression can be a method name, an inline statement, or omitted if there are modifiers present. The event type is denoted by the argument. self - only trigger handler if event was dispatched from this element. capture - add event listener in capture mode. Shorthand: Function | Inline Statement | Object (without argument)Īrgument: event (optional if using Object syntax) V-for can also work on values that implement the Iterable Protocol, including native Map and Set. Restriction: previous sibling element must have v-if or v-else-if. We don't recommend using these two directives together on one element - see the list rendering guide for details.ĭenote the "else block" for v-if or a v-if / v-else-if chain. When used together, v-if has a higher priority than v-for. This directive triggers transitions when its condition changes. If the initial condition is falsy, then the inner content won't be rendered at all.Ĭan be used on to denote a conditional block containing only text or multiple elements. When a v-if element is toggled, the element and its contained directives / components are destroyed and re-constructed. It also triggers transitions when its condition changes.Ĭonditionally render an element or a template fragment based on the truthy-ness of the expression value. V-show works by setting the display CSS property via inline styles, and will try to respect the initial display value when the element is visible. Toggle the element's visibility based on the truthy-ness of the expression value.
0 Comments
Leave a Reply. |