|
|
|
@ -1,44 +1,39 @@
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { BannerItem } from '@/types/home'
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
const activeIndex = ref(0)
|
|
|
|
|
|
|
|
|
|
const onchange: UniHelper.SwiperOnChange = (ev) => {
|
|
|
|
|
// 排除空值 类型断言
|
|
|
|
|
activeIndex.value = ev.detail!.current
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 接收父组件 传过来的数据 props --- 指定泛型(一个尖括号一个花括号)
|
|
|
|
|
defineProps<{
|
|
|
|
|
list: BannerItem[]
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
// const props = defineProps<{
|
|
|
|
|
// list: BannerItem[]
|
|
|
|
|
// }>()
|
|
|
|
|
|
|
|
|
|
// console.log(props, 'props')
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<view class="carousel">
|
|
|
|
|
<swiper :circular="true" :autoplay="false" :interval="3000">
|
|
|
|
|
<swiper-item>
|
|
|
|
|
<navigator url="/pages/index/index" hover-class="none" class="navigator">
|
|
|
|
|
<image
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
class="image"
|
|
|
|
|
src="https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/uploads/slider_1.jpg"
|
|
|
|
|
></image>
|
|
|
|
|
</navigator>
|
|
|
|
|
</swiper-item>
|
|
|
|
|
<swiper-item>
|
|
|
|
|
<navigator url="/pages/index/index" hover-class="none" class="navigator">
|
|
|
|
|
<image
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
class="image"
|
|
|
|
|
src="https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/uploads/slider_2.jpg"
|
|
|
|
|
></image>
|
|
|
|
|
</navigator>
|
|
|
|
|
</swiper-item>
|
|
|
|
|
<swiper-item>
|
|
|
|
|
<swiper @change="onchange" :circular="true" :autoplay="false" :interval="3000">
|
|
|
|
|
<swiper-item v-for="item in list" :key="item.id">
|
|
|
|
|
<navigator url="/pages/index/index" hover-class="none" class="navigator">
|
|
|
|
|
<image
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
class="image"
|
|
|
|
|
src="https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/uploads/slider_3.jpg"
|
|
|
|
|
></image>
|
|
|
|
|
<image mode="aspectFill" class="image" :src="item.imgUrl"></image>
|
|
|
|
|
</navigator>
|
|
|
|
|
</swiper-item>
|
|
|
|
|
</swiper>
|
|
|
|
|
<!-- 指示点 -->
|
|
|
|
|
<view class="indicator">
|
|
|
|
|
<text
|
|
|
|
|
v-for="(item, index) in 3"
|
|
|
|
|
v-for="(item, index) in list.length"
|
|
|
|
|
:key="item"
|
|
|
|
|
class="dot"
|
|
|
|
|
:class="{ active: index === activeIndex }"
|
|
|
|
|