0👍
Using the .
notation you’re directly pointing to the name you’ve supplied after the .
operator on a JS object.
To dynamically assign the accessing object key, you’ll need an approach like this:
this.$refs[fieldSwitchName].focus()
0👍
If switchToField is a variable, you need call $ref as array:
switchToField(fieldSwitchName, fieldValue, fieldLength) {
if (String(this.fieldValue).length >= fieldLength) {
this.$refs[fieldSwitchName].focus();
}
}
Source:stackexchange.com