学习Vue3 第二十三章(自定义指令)

44 阅读1分钟
<template>
  <input v-model="name" v-focus="{ background: 'red' }" />
  <div>{{ title }}</div>
</template>
<script setup>
import { ref, reactive, provide } from 'vue'
const title = ref('yoga')

// 直接使用 必须以v开头
const vFocus = {
  mounted: (...args) => {
    console.log('mounted', args)
    args.el.focus()
  },
}
</script>

<style scoped></style>