Home > Article > Web Front-end > The instruction for attribute binding in vue is
The attribute binding directive in Vue is v-bind, which allows dynamic binding of Vue data to HTML attributes. It is used as follows: use v-bind:attributename="expression", where attributename is the attribute name and expression is the JavaScript expression of data. Can be abbreviated to :attributename="expression". Note that the camelCase attribute needs to be converted to hyphenated form.
The directive for property binding in Vue
The directive for property binding in Vue is v-bind
.
Usage
v-bind
The v-bind
<code>v-bind:attributename="expression"</code>where:
attributename
expressionExample
The following example binds the
message data attribute to the
textContent of the p
element
<code class="vue"><p v-bind:textContent="message"></p></code>Abbreviated form
v-bind
The command can be abbreviated to
:
<code class="vue"><p :textContent="message"></p></code>Note
v-bind does not automatically convert camelCase attributes to hyphenated form. For example, to bind the
backgroundColor property, use
:background-color instead of
:backgroundColor
v-bind can be used in combination with other instructions, such as
v-on (event monitoring) and
v-modelThe above is the detailed content of The instruction for attribute binding in vue is. For more information, please follow other related articles on the PHP Chinese website!