2024-07-11
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
As mentioned above, in Vue3, custom directives are a powerful tool that allows us to extend the functionality of HTML elements. With custom directives, we can create reusable behaviors and bind them to any element. Below, this article backs up some simple Vue3 custom directive super practical cases and explains their actual application scenarios. :
v-focus - Automatically focus the input box
const app = Vue.createApp({
data() {
return {
// ...
}
}
});
app.directive('focus', {
mounted(el) {
el.focus();
}
});