[Vuejs]-Add placeholder dynamically vuejs

4👍

Try something like this:

1) Add a computed property to your component

computed: {
   placeholder() {
      return this.errors.has('end_date') ? 'Your placeholder text' : ''
   }
}

2) Bind to your computed placeholder property with v-bind:placeholder="placeholder"

0👍

you can get that done by saying :placeholder. Is that not working for you ? In your try you have a space between v-bind:placeholder. I think you should not be having that.

👤trk

0👍

<input
   type="text"
   v-model="FirstName"
   class="form-control"
   :placeholder="functionData"
/>

computed:{
   functionData(){
     return "Data"
  }
}

Leave a comment