Appearance
useWatchSwitch
▸ useWatchSwitch(source, options): void
监听状态,根据状态值切换开关状态
参数
| Name | Type | Default value | Description |
|---|---|---|---|
source | Function | Ref<any> | undefined | 需要监听的状态,支持传入 ref 和监听函数 |
options | Object | undefined | |
options.close | undefined | () => void | noop | 关闭 |
options.immediate | boolean | true | 立即执行 |
options.open | undefined | () => void | noop | 打开 |
返回值
void
示例
ts
useWatchSwitch(() => props.visible, {
open: () => nextTick(() => instance.refs.popup.open()),
close: () => nextTick(() => instance.refs.popup.close()),
})