Subscribe on changes!

component ref not working

avatar
Aug 16th 2022

Vue version

3.2.37

Link to minimal reproduction

https://sfc.vuejs.org/#eNp9kN1qAkEMhV8lBEEFnbmXbUH6GnOzaraOOD9MsrYgvnszs91ie1HYizmbnOQ7ueM+Z3MbCXfY8bH4LMAkY3510YecisBbChmGkgIsja2iti9d7OzUr53fTn3RZ/OcaOjHq8DdRYCQxih0Wq0nCSBnz2ZRaGDjYx7FDOk48mpdqw8X9XuarUIo5GsvpAqgazxqfnHY3A7BVgb704YbnNi3oc/mwilqurZbLa3ADnczjUPNU7XDs0jmnbU8HGvIC5tU3q2+TNEIPpAhDttDSR9MRQc7nJF15Xyaeskn4q5Bwm178PGkzItepKjzL3RL+u8dYx+oUtZFDjf1l49nKl72dWQtDf2VNcvvG+LjCyqfqTc=

Steps to reproduce

in devtools -> console, you can see error: TypeError: this.$refs.input.focus is not a function

What is expected?

input element is focused on initial load

What is actually happening?

TypeError: this.$refs.input.focus is not a function

System Info

No response

Any additional comments?

No response

avatar
Aug 17th 2022

you should add the focus method in Comp.vue. see demo