lex 1 year ago
parent
commit
f90ae47e29
2 changed files with 11 additions and 5 deletions
  1. 9 3
      src/components/m-sticky/index.tsx
  2. 2 2
      vite.config.ts

+ 9 - 3
src/components/m-sticky/index.tsx

@@ -9,6 +9,7 @@ import {
 } from 'vue';
 import styles from './index.module.less';
 import { useRect } from '@vant/use';
+import { useResizeObserver } from '@vueuse/core';
 
 export default defineComponent({
   name: 'm-sticky',
@@ -62,11 +63,16 @@ export default defineComponent({
       } else {
         forms.divStyle.bottom = props.offsetBottom || '0px';
       }
-      const resize = new ResizeObserver(() => {
-        const { height } = useRect(div2Ref.value);
+      // const resize = new ResizeObserver(() => {
+      //   const { height } = useRect(div2Ref.value);
+      //   __initHeight(height);
+      // });
+      // resize.observe(divRef.value);
+      useResizeObserver(divRef.value, (entries: any) => {
+        const entry = entries[0];
+        const { height } = entry.contentRect;
         __initHeight(height);
       });
-      resize.observe(divRef.value);
 
       // nextTick(() => {
       //   // 为了处理刚开始头部高度为0的情况

+ 2 - 2
vite.config.ts

@@ -13,9 +13,9 @@ function resolve(dir: string) {
 }
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
-// const proxyUrl = 'https://test.lexiaoya.cn/';
+const proxyUrl = 'https://test.lexiaoya.cn/';
 // const proxyUrl = 'https://dev.kt.colexiu.com/';
-const proxyUrl = 'http://192.168.3.143:7989/';
+// const proxyUrl = 'http://192.168.3.143:7989/';
 export default defineConfig({
   base: './',
   plugins: [