<template>
<button @click="focusInput">Click me to focus on the input</button>
<input ref="inputField" type="text">
</template>
<script setup>
const focusInput = () => {
this.$refs.inputField.focus();
};
</script>
I'm trying to set the focus into the input field on a button click but does not work with Vue 3. Really appreciate it if somebody can help. Thanks