[Vuejs]-How to access vuejs refs if ref value has bracket character

0👍

you should change something like below:

best practice:

// sample in template template:

<input type="text" class="form-control form-control-sm" v-bind:value=meminfo.last_name name="online_membership[last_name]" :ref="online_membership[last_name]" >

Script:

methods() {
   function() {
     // i would like to access the input value of this ref
     this.$refs[online_membership[last_name]]
   }
}

but still if you want to use as a string including ‘[‘ then simply you can use below solution:

// sample in template template:

<input type="text" class="form-control form-control-sm" v-bind:value=meminfo.last_name name="online_membership[last_name]" ref="'online_membership[last_name]'" >

Script:

methods() {
   function() {
     // i would like to access the input value of this ref
     this.$refs['online_membership[last_name]']
   }
}

hope it will solve your problem

Leave a comment