diff --git a/pages/component/swiper/swiper.uvue b/pages/component/swiper/swiper.uvue index 35bafccd1733d47a8d86f2f829751b1bab292525..29154d0096a1122515e51497b068b2057b507069 100644 --- a/pages/component/swiper/swiper.uvue +++ b/pages/component/swiper/swiper.uvue @@ -130,9 +130,11 @@ onReady() { // 获取模拟滑动手势的起始点 let ele = uni.getElementById("swiper-view") - let eleRect = ele?.getBoundingClientRect() - this.swipeX = eleRect!.width - 10 - this.swipeY += eleRect!.y + uni.getSystemInfoSync().safeArea.top + 44 + 35 + let eleRect = ele?.getBoundingClientRect() + if(eleRect != null) { + this.swipeX = eleRect.width - 10 + this.swipeY += eleRect.y + uni.getSystemInfoSync().safeArea.top + 44 + 35 + } }, methods: { swipertouchStart(e: UniTouchEvent) {