Skip to content

onStartTyping

当用户开始在不可编辑的元素上键入时触发。

¥Fires when users start typing on non-editable elements.

示例

Type anything

用法

¥Usage

vue
<script setup lang="ts">
import { 
onStartTyping
} from '@vueuse/core'
import {
useTemplateRef
} from 'vue'
const
input
=
useTemplateRef
('input')
onStartTyping
(() => {
if (!
input
.
value
.active)
input
.
value
.
focus
()
}) </script> <template> <
input
ref
="
input
"
type
="text"
placeholder
="Start typing to focus">
</template>