Skip to content Skip to sidebar Skip to footer

How To Set Value To Input Field In Vuejs

below i

Solution 1:

Try using the ref property, see here: https://vuejs.org/v2/api/#ref Basically would look something like:


    <va-input label="Address 1"
              v-model="Address1"id="address"
              class="inp"
              ref="inputRef"
    >
         </va-input>
    ...
    this.$refs.inputRef.$el.value = ...

You may need to dig a little into the structure but from the $el you can access the element.

Solution 2:

You need to add this data to the "data" of the component, just create :

`data() {
    return {
        Address1: ''
    }
}`

and at the created() or anywhere you want to assign this value : this.Adress1 = res.data[0].address1

Basically this is the vue way of doing these kind of things,and using the v-model properly.

Post a Comment for "How To Set Value To Input Field In Vuejs"