其他分享
首页 > 其他分享> > How to add dynamically attribute in VueJs

How to add dynamically attribute in VueJs

作者:互联网

How to add dynamically attribute in VueJs

base one condition we can define or change attributes in vue

Please refer official document for the same https://vuejs.org/v2/guide/syntax.html#Attributes

 

you can add an attribute like v-for="(item, index) in numbers" :mycustom="item" , if there's an array [1,2,3,4]

Attributes

Mustaches cannot be used inside HTML attributes. Instead, use a v-bind directive:

<div v-bind:id="dynamicId"></div>

In the case of boolean attributes, where their mere existence implies true, v-bind works a little differently. In this example:

<button v-bind:disabled="isButtonDisabled">Button</button>

If isButtonDisabled has the value of null, undefined, or false, the disabled attribute will not even be included in the rendered <button> element.

标签:VueJs,attribute,dynamically,How,add,Attributes,attributes
来源: https://www.cnblogs.com/chucklu/p/14200203.html