|
|
@ -1,44 +1,39 @@
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
|
|
import type { BannerItem } from '@/types/home'
|
|
|
|
import { ref } from 'vue'
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
|
|
const activeIndex = ref(0)
|
|
|
|
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>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<view class="carousel">
|
|
|
|
<view class="carousel">
|
|
|
|
<swiper :circular="true" :autoplay="false" :interval="3000">
|
|
|
|
<swiper @change="onchange" :circular="true" :autoplay="false" :interval="3000">
|
|
|
|
<swiper-item>
|
|
|
|
<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_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>
|
|
|
|
|
|
|
|
<navigator url="/pages/index/index" hover-class="none" class="navigator">
|
|
|
|
<navigator url="/pages/index/index" hover-class="none" class="navigator">
|
|
|
|
<image
|
|
|
|
<image mode="aspectFill" class="image" :src="item.imgUrl"></image>
|
|
|
|
mode="aspectFill"
|
|
|
|
|
|
|
|
class="image"
|
|
|
|
|
|
|
|
src="https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/uploads/slider_3.jpg"
|
|
|
|
|
|
|
|
></image>
|
|
|
|
|
|
|
|
</navigator>
|
|
|
|
</navigator>
|
|
|
|
</swiper-item>
|
|
|
|
</swiper-item>
|
|
|
|
</swiper>
|
|
|
|
</swiper>
|
|
|
|
<!-- 指示点 -->
|
|
|
|
<!-- 指示点 -->
|
|
|
|
<view class="indicator">
|
|
|
|
<view class="indicator">
|
|
|
|
<text
|
|
|
|
<text
|
|
|
|
v-for="(item, index) in 3"
|
|
|
|
v-for="(item, index) in list.length"
|
|
|
|
:key="item"
|
|
|
|
:key="item"
|
|
|
|
class="dot"
|
|
|
|
class="dot"
|
|
|
|
:class="{ active: index === activeIndex }"
|
|
|
|
:class="{ active: index === activeIndex }"
|
|
|
|