mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
feat: ✨ swiper新增default slot 用户可自定义swiper-item中的内容展示 (#1164)
* feat: ✨ swiper新增default slot 用户可自定义swiper-item中的内容展示 * docs: ✏️ 补充swiper组件使用说明
This commit is contained in:
parent
7466c91c1a
commit
046b135a14
@ -299,6 +299,24 @@ const current = ref <number>(0)
|
||||
const isLoop = ref(false)
|
||||
```
|
||||
|
||||
|
||||
## slot插槽自定义内容
|
||||
```html
|
||||
<wd-swiper
|
||||
:list="swiperList"
|
||||
autoplay
|
||||
v-model:current="current"
|
||||
:indicator="{ type: 'dots' }"
|
||||
@click="handleClick"
|
||||
@change="onChange"
|
||||
>
|
||||
<template v-slot="{ item, index }">
|
||||
<view class="custom-indicator" style="position: absolute; bottom: 24rpx; right: 24rpx">{{ index + 1 }}/{{ item }}</view>
|
||||
</template>
|
||||
</wd-swiper>
|
||||
```
|
||||
|
||||
|
||||
## Attributes
|
||||
|
||||
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
|
||||
@ -384,6 +402,7 @@ const isLoop = ref(false)
|
||||
| name | 说明 | 参数 | 最低版本 |
|
||||
| --------- | ------------ | ------------------------------------ | -------- |
|
||||
| indicator | 自定义指示器 | `{ current: number, total: number }` | 0.1.22 |
|
||||
| default | item展示内容 | `{ item: any, index: number }` | 0.1.22 |
|
||||
|
||||
|
||||
## 外部样式类
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
@animationfinish="handleAnimationfinish"
|
||||
>
|
||||
<swiper-item v-for="(item, index) in list" :key="index" class="wd-swiper__item">
|
||||
<slot :item="item" :index="index">
|
||||
<video
|
||||
v-if="isVideo(item)"
|
||||
:id="`video-${index}-${uid}`"
|
||||
@ -47,8 +48,10 @@
|
||||
:mode="imageMode"
|
||||
@click="handleClick(index, item)"
|
||||
/>
|
||||
|
||||
<text v-if="isObj(item) && item[textKey]" :class="`wd-swiper__text ${customTextClass}`" :style="customTextStyle">{{ item[textKey] }}</text>
|
||||
<text v-if="isObj(item) && item[textKey]" :class="`wd-swiper__text ${customTextClass}`" :style="customTextStyle">
|
||||
{{ item[textKey] }}
|
||||
</text>
|
||||
</slot>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user