0👍
You could try simply reset focus manually using focus()
method on the ref
object.
You will need to add ref
attribute to the input.
<input ref="applyToAll" id="applyToAll" class="custom-control-input" type="checkbox" @change="applyToAll"/>
<div v-for="(data,index) in users">
<div :key="index">
<input v-model="data.contactInfo.phoneNumber">
</div>
</div>
And your applyToAll
method:
applyToAll() {
if (this.appliedToAll) {
const copiedPhone = this.users[0].contactInfo.phoneNumber;
this.users[1].contactInfo.phoneNumber = copiedPhone;
this.users[2].contactInfo.phoneNumber = copiedPhone;
} else {
this.users[1].contactInfo.phoneNumber = '';
this.users[2].contactInfo.phoneNumber = '';
}
this.$refs.applyToAll.focus();
}
- [Vuejs]-Why my Front-End requests are all sended to Back-End project?
- [Vuejs]-Safari iframe's service worker loops infinitely and iframe is a white screen (not in other browsers, not in a new tab)
Source:stackexchange.com