How to add dynamically attribute in VueJs How to add dynamically attribute in VueJs vue.js vue.js

How to add dynamically attribute in VueJs


You can bind it to a variable using v-bind:disabled="foo" or :disabled="foo" for short:

<textfield label="Name" value.sync="el.name" :disabled="myVar">

Then in Vue you can just set this.myVar = true and it will disable the input.

Edit: add this to your template:

<template>  <input type="text" :disabled="disabled" :placeholder="placeholder" v-model="value"></template>


As pointed out, you don't need dynamic attributes in your case.

But well, you asked if it is possible, and the answer is yes. You can have dynamic attributes, as of 2.6.0.

Example:

<a v-bind:[attributeName]="whatever">

It is documented here


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