feat(MineTask): 添加问卷滑动切换功能

- 在 QuestionList 组件中添加 slideChange 事件监听
- 在 MineTask 组件中实现 slideChange 方法,调整滑动后问卷区域高度
-通过自定义事件和回调函数实现问卷页滑动切换时的高度自适应
This commit is contained in:
陈昱达
2025-05-26 17:57:55 +08:00
parent 65c783ff02
commit ef854a51f8
2 changed files with 21 additions and 0 deletions

View File

@@ -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() {
<van-swipe :loop="false" @drag-start="handleDragStart" @drag-end="handleDragEnd" ref="swiper">
<van-swipe-item v-for="question in surveys" :key="question?.sn">
<question-list
@slideChange="slideChange"
:parentRef="swiper"
:survey="question"
style="max-width: 100vw; overflow: hidden"
ref="questionComat"