mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 01:41:20 +08:00
d28d0701d7
* docs: remove unused code * refactor(docs): improve code
17 lines
415 B
TypeScript
17 lines
415 B
TypeScript
import { isRef, ref } from 'vue'
|
|
import { isBoolean } from '@vueuse/core'
|
|
import type { MaybeRef } from '@vueuse/core'
|
|
|
|
export const useToggle = (getToggled?: MaybeRef<boolean>) => {
|
|
const val = isRef(getToggled)
|
|
? getToggled
|
|
: ref(isBoolean(getToggled) ? getToggled : false)
|
|
|
|
return [
|
|
val,
|
|
(toggle?: boolean) => {
|
|
val.value = isBoolean(toggle) ? toggle : !val.value
|
|
},
|
|
] as const
|
|
}
|