Create a custom directive v-focus that focuses the input on mount.
Code Playground
JavaScript (V8)
Loading...
Console Output
// Output will appear here...
// For React: ReactDOM.createRoot(rootElement).render(<App />);
// For React: ReactDOM.createRoot(rootElement).render(<App />);
Recommended Answer
<template>
<input v-focus />
</template>
<script setup>
const vFocus = {
mounted: (el) => el.focus()
}
</script>