mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-06 07:36:35 +08:00
18 lines
362 B
TypeScript
18 lines
362 B
TypeScript
import { ref, watch, WatchSource } from 'vue';
|
|
|
|
export function useLazyRender(show: WatchSource<boolean | undefined>) {
|
|
const inited = ref(false);
|
|
|
|
watch(
|
|
show,
|
|
(value) => {
|
|
if (value) {
|
|
inited.value = value;
|
|
}
|
|
},
|
|
{ immediate: true }
|
|
);
|
|
|
|
return (render: () => JSX.Element) => () => (inited.value ? render() : null);
|
|
}
|