ရိုးရိုးလေး ရှင်းပြမယ်
Custom directive ကို low-level DOM behavior ပြန်လည်အသုံးပြုလိုသောအခါသာသုံးပါ။ UI structure ပါလျှင် component သို့မဟုတ် composable ပိုသင့်တော်သည်။ App-wide services နှင့် directives စုစည်းရန် plugin ၏ install(app) ကိုသုံးနိုင်သည်။
vue
<script setup>
const vFocus = {
mounted(element) {
element.focus()
}
}
</script>
<template>
<label>
Search
<input v-focus placeholder="Type to search">
</label>
</template>You should see
Search input receives focus after mountလက်တွေ့စမ်းကြည့်ရန်
Element အပြင်ဘက် click လျှင် callback ခေါ်သော v-click-outside custom directive တစ်ခုရေးပါ။
Custom Directives — Vue.js