EASYAIuniappNewUI/node_modules/@tuniao/tnui-vue3-uniapp/hooks/use-toggle/index.ts
2025-02-08 18:50:38 +08:00

12 lines
265 B
TypeScript

import { ref } from 'vue'
import type { Ref } from 'vue'
export const useToggle = (initState: boolean): [Ref<boolean>, () => void] => {
const state = ref<boolean>(initState)
const toggle = () => {
state.value = !state.value
}
return [state, toggle]
}