kun-galgame-vue/src/utils/toggle.ts
2023-06-09 18:22:45 +08:00

19 lines
310 B
TypeScript

import { ref } from 'vue'
const toggleStatus = (initState: boolean, delay: number) => {
const on = ref(initState ?? false)
const toggle = (value: boolean) => {
setTimeout(() => {
on.value = value ?? !on.value
}, delay)
}
return {
on,
toggle,
}
}
export default toggleStatus