Vue.js - this.$refs.key returns an empty array or undefined instead of element Vue.js - this.$refs.key returns an empty array or undefined instead of element vue.js vue.js

Vue.js - this.$refs.key returns an empty array or undefined instead of element


I strongly suggest considering these 2 good practices first:

Once that's taken care of, I'd suggest adding an index to your v-for and adding the :ref to the individual buttons so you can find each one of them in a function.

Working with array items via ref is rather well described here: this.$refs[("p" + index)].focus is not a function

You should be able to apply focus to the first button using something like this.$refs[button${index}][0].focus();