|
@@ -63,31 +63,36 @@ export default defineComponent({
|
|
|
} else {
|
|
|
forms.divStyle.bottom = props.offsetBottom || '0px';
|
|
|
}
|
|
|
-
|
|
|
- nextTick(() => {
|
|
|
- // 为了处理刚开始头部高度为0的情况
|
|
|
- if (divRef.value) {
|
|
|
- const { height } = useRect(divRef.value);
|
|
|
+ const resize = new ResizeObserver(() => {
|
|
|
+ const { height } = useRect(divRef.value);
|
|
|
__initHeight(height);
|
|
|
+ })
|
|
|
+ resize.observe(divRef.value);
|
|
|
+
|
|
|
+ // nextTick(() => {
|
|
|
+ // // 为了处理刚开始头部高度为0的情况
|
|
|
+ // if (divRef.value) {
|
|
|
+ // const { height } = useRect(divRef.value);
|
|
|
+ // __initHeight(height);
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- const { height } = useRect(divRef.value);
|
|
|
- // 判断获取的高度是否一致,如果一致则不做处理
|
|
|
- if (height === forms.heightV) return;
|
|
|
- __initHeight(height);
|
|
|
- }, 200);
|
|
|
- }
|
|
|
+ // setTimeout(() => {
|
|
|
+ // const { height } = useRect(divRef.value);
|
|
|
+ // // 判断获取的高度是否一致,如果一致则不做处理
|
|
|
+ // if (height === forms.heightV) return;
|
|
|
+ // __initHeight(height);
|
|
|
+ // }, 200);
|
|
|
+ // }
|
|
|
|
|
|
- // 为了处理头部第一次获取高度不对的问题
|
|
|
- if (div2Ref.value) {
|
|
|
- setTimeout(() => {
|
|
|
- const { height } = useRect(div2Ref.value);
|
|
|
- if (height !== forms.heightV && props.position === 'top') {
|
|
|
- __initHeight(height);
|
|
|
- }
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- });
|
|
|
+ // // 为了处理头部第一次获取高度不对的问题
|
|
|
+ // if (div2Ref.value) {
|
|
|
+ // setTimeout(() => {
|
|
|
+ // const { height } = useRect(div2Ref.value);
|
|
|
+ // if (height !== forms.heightV && props.position === 'top') {
|
|
|
+ // __initHeight(height);
|
|
|
+ // }
|
|
|
+ // }, 1000);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
});
|
|
|
|
|
|
watch(
|