12 lines
265 B
TypeScript
Raw Permalink Normal View History

2024-11-05 10:09:18 +08:00
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]
}