vue.js instruction

Command (Directives) with a v-special attribute prefix. The expected value of the instruction attribute is a single JavaScript expression ( v-forare exceptions, we discuss later).

parameter

Some instructions capable of receiving a "parameter", represented by the colon after the instruction name. For example, v-bindinstructions may be used responsively update HTML attribute:

<a v-bind:href="url">...</a>

Here hrefare parameters, informing v-bindthe instruction element in the hrefattribute of the expression urlvalues of binding.

Dynamic parameters

 2.6.0 From the start, using square brackets in JavaScript expression as a parameter of a command:

<a v-bind:[attributeName]="url"> ... </a>

Here attributeNameis a JavaScript expression as the dynamic evaluation, obtained value will be used as the final argument. For example, if you have a Vue instance dataattribute attributeNamewhose value "href", then this would be equivalent to the binding v-bind:href.

Constraints on the values ​​of the dynamic parameters

A dynamic parameter string is expected to be determined, the value of the abnormality null. This special nullvalue can be explicitly used to remove the binding. Any value other non-string types are will trigger a warning.

Constraints on dynamic parameters of expression

Dynamic parameter expression syntax has some constraints, because certain characters, such as spaces and quotation marks, placed in HTML attribute name is invalid.

When using a template in the DOM (direct writing template in an HTML file), you also need to avoid using uppercase characters to name the key name, because the browser will attribute names all forced to lower case.

Guess you like

Origin www.cnblogs.com/1016391912pm/p/12554695.html