I’m having difficulties trying to change focus from one input to another by pressing the next button in android/ios keyboard since there is no example for the usage of setFocus
method.
Maybe somebody here has already achieved this before? Can anyone please show me some example?
What I’ve tried so far:
// template
<form-input
enterkeyhint="next"
@keyup.enter="changeFocus('password')"
/>
<form-input
ref="password"
/>
// .ts
methods: {
changeFocus(nextFocus: string): void {
this.$refs[nextFocus].setFocus();
},
},
// errors
TS2571: Object is of type 'unknown'.
[vue-cli-service] 80 | methods: {
[vue-cli-service] 81 | changeFocus(nextFocus: string): void {
[vue-cli-service] > 82 | this.$refs[nextFocus].setFocus();
[vue-cli-service] | ^^^^^^^^^^^^^^^^^^^^^
[vue-cli-service] 83 | },
[vue-cli-service] 84 | },
[vue-cli-service] 85 | });