|
@@ -1,4 +1,3 @@
|
|
|
-import { useRect } from '@vant/use'
|
|
|
import { defineComponent, nextTick, PropType } from 'vue'
|
|
|
import styles from './index.module.less'
|
|
|
import { useResizeObserver } from '@vueuse/core'
|
|
@@ -39,6 +38,10 @@ export default defineComponent({
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
+ // 增加判断如果不支持当前依赖再设置即可
|
|
|
+ if (window.ResizeObserver === undefined) {
|
|
|
+ window.ResizeObserver = ResizeObserver
|
|
|
+ }
|
|
|
if (this.position === 'top') {
|
|
|
this.divStyle.top = this.offsetTop || '0px'
|
|
|
} else {
|
|
@@ -56,28 +59,27 @@ export default defineComponent({
|
|
|
}, 10)
|
|
|
}
|
|
|
})
|
|
|
- } catch {
|
|
|
+ } catch (e) {
|
|
|
//
|
|
|
+ console.log(e, 'error useResizeObserver')
|
|
|
}
|
|
|
|
|
|
- // nextTick(() => {
|
|
|
- // // 为了处理刚开始头部高度为0的情况
|
|
|
- // const { height } = useRect((this as any).$refs.div)
|
|
|
- // this.__initHeight(height)
|
|
|
-
|
|
|
- // setTimeout(() => {
|
|
|
- // const { height } = useRect((this as any).$refs.div)
|
|
|
- // this.__initHeight(height)
|
|
|
- // }, 200)
|
|
|
-
|
|
|
- // // 为了处理头部第一次获取高度不对的问题
|
|
|
- // setTimeout(() => {
|
|
|
- // const { height } = useRect((this as any).$refs.div2)
|
|
|
- // if (height !== this.heightV && this.position === 'top') {
|
|
|
- // this.__initHeight(height)
|
|
|
- // }
|
|
|
- // }, 1000)
|
|
|
- // })
|
|
|
+ nextTick(() => {
|
|
|
+ // // 为了处理刚开始头部高度为0的情况
|
|
|
+ // const { height } = useRect((this as any).$refs.div)
|
|
|
+ // this.__initHeight(height)
|
|
|
+ // setTimeout(() => {
|
|
|
+ // const { height } = useRect((this as any).$refs.div)
|
|
|
+ // this.__initHeight(height)
|
|
|
+ // }, 200)
|
|
|
+ // // 为了处理头部第一次获取高度不对的问题
|
|
|
+ // setTimeout(() => {
|
|
|
+ // const { height } = useRect((this as any).$refs.div2)
|
|
|
+ // if (height !== this.heightV && this.position === 'top') {
|
|
|
+ // this.__initHeight(height)
|
|
|
+ // }
|
|
|
+ // }, 1000)
|
|
|
+ })
|
|
|
},
|
|
|
methods: {
|
|
|
__initHeight(height: any) {
|