Can we bind value directly in vuejs like, v-bind:value=" 'India' "

Viewed 151

Can we bind value directly like

v-bind:value="'India'"

Suppose I have field,

 <input id="country" type="text" 
      class="form-control" 
      name="country" placeholder="country" v-bind:value="'India'" v-model="fields.country">

throw error

v-bind:value="'India'" conflicts with v-model on the same element because the latter already expands to a value binding internally

Using laravel 7.x and vue 2.5

2 Answers

Don't do that. V-model already binds the fields.country value to the input. If you want a default value to be defined before, try assigning it to fields.country like fields.country = "India"

Just give fields.country an initial value. Notice in order to make fields.country reactive, you also need to declare country property in fields:

data () {
  return {
    fields: {
      country: 'India'
    }
  }
}

No need for v-bind:value in your template:

 <input id="country" type="text" 
      class="form-control" 
      name="country" placeholder="country" v-model="fields.country">
Related