feat(MineTask): 添加轮播图分页器
- 在标题栏添加分页器组件 - 实现分页器的动态显示和切换 - 优化轮播图样式,使其更加美观
This commit is contained in:
@@ -1,31 +1,56 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import QuestionList from './components/QuestionList.vue';
|
import QuestionList from './components/QuestionList.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
const active = ref(0);
|
||||||
|
const total = ref(0);
|
||||||
const surveys = defineModel('surveys', { required: true });
|
const surveys = defineModel('surveys', { required: true });
|
||||||
|
function setActive(act, tol) {
|
||||||
|
active.value = act;
|
||||||
|
total.value = tol;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="carousel-container">
|
<div class="carousel-container">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<span>我的任务</span>
|
<span>我的任务</span>
|
||||||
|
<div class="carousel-indicators">
|
||||||
|
<i
|
||||||
|
v-for="(item, index) in total"
|
||||||
|
class="van-swipe__indicator"
|
||||||
|
:class="active === index ? 'van-swipe__indicator--active' : ''"
|
||||||
|
></i>
|
||||||
|
</div>
|
||||||
|
<!--分页器。如果放置在swiper外面,需要自定义样式。-->
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<van-swipe>
|
||||||
|
<van-swipe-item v-for="question in surveys" :key="question?.sn">
|
||||||
|
<question-list :survey="question" style="max-width: 100vw; overflow: hidden" />
|
||||||
|
</van-swipe-item>
|
||||||
|
|
||||||
|
<template #indicator="{ active, total }">
|
||||||
|
{{ setActive(active, total) }}
|
||||||
|
</template>
|
||||||
|
</van-swipe>
|
||||||
</div>
|
</div>
|
||||||
<van-swipe>
|
|
||||||
<van-swipe-item v-for="question in surveys" :key="question?.sn">
|
|
||||||
<question-list :survey="question" style="max-width: 100vw; overflow: hidden" />
|
|
||||||
</van-swipe-item>
|
|
||||||
</van-swipe>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@use '@/assets/css/theme';
|
@use '@/assets/css/theme';
|
||||||
|
.carousel-indicators {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
transform: translate(-50%);
|
||||||
|
}
|
||||||
.carousel-container {
|
.carousel-container {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: theme.$gap;
|
margin-top: theme.$gap;
|
||||||
border-radius: theme.$card-radius;
|
border-radius: theme.$card-radius;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
color: black;
|
color: black;
|
||||||
@@ -33,6 +58,9 @@ const surveys = defineModel('surveys', { required: true });
|
|||||||
font-family: PingFangSC-Heavy;
|
font-family: PingFangSC-Heavy;
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.carousel-item {
|
.carousel-item {
|
||||||
|
|||||||
Reference in New Issue
Block a user