|
@@ -188,16 +188,35 @@ export default defineComponent({
|
|
|
* @description 重置当前的题目高度
|
|
|
* @param {any} scroll 是否滚动到顶部
|
|
|
*/
|
|
|
+ let size = 0
|
|
|
const resizeSwipeItemHeight = (scroll = true) => {
|
|
|
nextTick(() => {
|
|
|
scroll && window.scrollTo(0, 0)
|
|
|
setTimeout(() => {
|
|
|
- // const currentItemDom: Element =
|
|
|
- // document.querySelectorAll('.swipe-item-question')[state.currentIndex]
|
|
|
- // console.log(document.querySelectorAll('.van-swipe-item'), state.currentIndex)
|
|
|
const currentItemDom: any = document
|
|
|
.querySelectorAll('.van-swipe-item')
|
|
|
[state.currentIndex]?.querySelector('.swipe-item-question')
|
|
|
+ console.log('🚀 ~ setTimeout ~ currentItemDom', currentItemDom)
|
|
|
+
|
|
|
+ const allImg = currentItemDom.querySelectorAll('.answerTitleImg img')
|
|
|
+ let status = true
|
|
|
+ // console.log(allImg)
|
|
|
+ allImg.forEach((img: any) => {
|
|
|
+ console.log(img.complete)
|
|
|
+ if (!img.complete) {
|
|
|
+ status = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 判断图片是否加载完了
|
|
|
+ if (!status && size < 3) {
|
|
|
+ setTimeout(() => {
|
|
|
+ size += 1
|
|
|
+ resizeSwipeItemHeight(scroll)
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ if (status) {
|
|
|
+ size = 0
|
|
|
+ }
|
|
|
const rect = useRect(currentItemDom)
|
|
|
state.swipeHeight = rect.height
|
|
|
}, 100)
|