kun-galgame-vue/src/utils/toggle.ts

19 lines
310 B
TypeScript
Raw Normal View History

2023-06-09 10:22:45 +00:00
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