💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## useFocus ``` const target = ref() const { focused } = useFocus(target) watch(focused, (focused) => { if (focused) console.log('input element has been focused') else console.log('input element has lost focus') }) ``` 初始激活值 ``` import { useFocus } from '@vueuse/core' const target = ref() const { focused } = useFocus(target, { initialValue: true }) ``` ## useFocusWithin 指定元素没有被激活 ``` import { useFocusWithin } from '@vueuse/core' const target = ref(); const { focused } = useFocusWithin(target) watch(focused, focused => { if (focused) console.log('Target contains the focused element') else console.log('Target does NOT contain the focused element') }) ```