From ef854a51f871ee0aee9f33c13547f206d7863d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=B1=E8=BE=BE?= Date: Mon, 26 May 2025 17:57:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(MineTask):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=97=AE=E5=8D=B7=E6=BB=91=E5=8A=A8=E5=88=87=E6=8D=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 QuestionList 组件中添加 slideChange 事件监听 - 在 MineTask 组件中实现 slideChange 方法,调整滑动后问卷区域高度 -通过自定义事件和回调函数实现问卷页滑动切换时的高度自适应 --- src/views/Home/components/MineTask/Index.vue | 11 +++++++++++ .../components/MineTask/components/QuestionList.vue | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/views/Home/components/MineTask/Index.vue b/src/views/Home/components/MineTask/Index.vue index b8e65c5..50804c1 100644 --- a/src/views/Home/components/MineTask/Index.vue +++ b/src/views/Home/components/MineTask/Index.vue @@ -24,6 +24,15 @@ watch( }, 500); } ); +function slideChange() { + console.log(1); + setTimeout(() => { + console.log(swiper.value.$el.style.height); + // 获取高度 + swiper.value.$el.style.height = questionComat.value[active.value].$el.scrollHeight + 30 + 'px'; + swiper.value.resize(); + }, 500); +} function handleDragEnd() { isDrag.value = false; // setTimeout(() => { @@ -52,6 +61,8 @@ function handleDragEnd() { ('survey'); +const parentRef = defineModel('parentRef'); // 获取问卷分析数据 const { questionAnalysis } = useFetchAnalysis(survey.value?.sn as string); const { currentSurvey } = fetchSingleSurvey(survey.value?.sn as string); const disableInsight = ref(true); + +// 定义事件 +const emit = defineEmits(['slideChange']); +const slideChange = function (swiper) { + parentRef.value.resize(); + emit('slideChange', { swiper, activeIndex: swiper.activeIndex }); +};