mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
18 lines
351 B
TypeScript
18 lines
351 B
TypeScript
import { ref, watch, WatchSource, VNode } from 'vue';
|
|
|
|
export function useLazyRender(show: WatchSource<boolean>) {
|
|
const inited = ref(false);
|
|
|
|
watch(
|
|
show,
|
|
(value) => {
|
|
if (value) {
|
|
inited.value = value;
|
|
}
|
|
},
|
|
{ immediate: true }
|
|
);
|
|
|
|
return (render: () => VNode) => () => (inited.value ? render() : null);
|
|
}
|