更新记录
首次发布
平台兼容性
uni-app(4.06)
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
- |
√ |
√ |
- |
√ |
- |
- |
- |
√ |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
√ |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
xhs-swiper-dot
这是一个仿小红书的轮播图指示器(指示点)
用法
<view class="section">
<view class="title">仿小红书轮播图指示器</view>
<swiper class="swiper"
:indicator-dots="false"
:current="current"
@change="e => current = e.detail.current"
>
<swiper-item v-for="(item, index) in colors" :key="index">
<view class="swiper-item" :style="{background: item}">
{{ index + 1 < 10 ? `0${index + 1}` : index + 1 }}
</view>
</swiper-item>
</swiper>
<xhs-swiper-dot :dot-size="16" :total="colors.length" :current="current" />
</view>
引入组件后,直接在swiper组件下方添加该组件,然后传入轮播图的总数以及轮播图的索引(即swiper组件的current属性)。
组件props
参数 |
说明 |
类型 |
默认值 |
total |
轮播图的总数,必传 |
number |
- |
current |
当前轮播图的索引,传入swiper组件的current |
number |
0 |
dotSize |
指示点的大小,单位rpx,建议不要超过20 |
number |
16 |
dotColor |
指示点的颜色 |
string |
'#aaa' |
activeDotColor |
当前激活的指示点的颜色 |
string |
'red' |
hideOnSingleDot |
当只有一个指示点时是否隐藏指示器 |
boolean |
true |