mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-01 21:56:35 +08:00
types: use-placeholder
This commit is contained in:
parent
4c468ffd74
commit
63f15094f3
@ -1,14 +0,0 @@
|
|||||||
import { useHeight } from './use-rect';
|
|
||||||
|
|
||||||
export function usePlaceholder(contentRef, bem) {
|
|
||||||
const height = useHeight(contentRef);
|
|
||||||
|
|
||||||
return (renderContent) => (
|
|
||||||
<div
|
|
||||||
class={bem('placeholder')}
|
|
||||||
style={{ height: height.value ? `${height.value}px` : null }}
|
|
||||||
>
|
|
||||||
{renderContent()}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
16
src/composition/use-placeholder.tsx
Normal file
16
src/composition/use-placeholder.tsx
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { useHeight } from './use-rect';
|
||||||
|
import type { Ref, VNode } from 'vue';
|
||||||
|
import type { BEM } from '../utils/create/bem';
|
||||||
|
|
||||||
|
export function usePlaceholder(contentRef: Ref<Element>, bem: BEM) {
|
||||||
|
const height = useHeight(contentRef);
|
||||||
|
|
||||||
|
return (renderContent: () => VNode) => (
|
||||||
|
<div
|
||||||
|
class={bem('placeholder')}
|
||||||
|
style={{ height: height.value ? `${height.value}px` : undefined }}
|
||||||
|
>
|
||||||
|
{renderContent()}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user