Command (Directives) with a v-
special attribute prefix. The expected value of the instruction attribute is a single JavaScript expression ( v-for
are exceptions, we discuss later).
parameter
Some instructions capable of receiving a "parameter", represented by the colon after the instruction name. For example, v-bind
instructions may be used responsively update HTML attribute:
<a v-bind:href="url">...</a>
Here href
are parameters, informing v-bind
the instruction element in the href
attribute of the expression url
values 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 attributeName
is a JavaScript expression as the dynamic evaluation, obtained value will be used as the final argument. For example, if you have a Vue instance data
attribute attributeName
whose 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 null
value 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.