更新记录

0.0.1(2025-02-28) 下载此版本

  • init

平台兼容性

Vue2 Vue3
×
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 4.45 app-vue app-uvue × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序 鸿蒙元服务
× × × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × ×

lime-swiper-dot 轮播图指示点

  • 自定义轮播图指示点组件
  • 插件依赖lime-style,lime-shared不喜勿下

文档

swiper-dot

安装

插件市场导入即可,首次导入可能需要重新编译

代码演示

基础使用

使用 position: relative 的容器包裹轮播组件和指示器组件,通过type:指定指示器类型,可选值:

  • dot:圆形指示点
  • dot-bar:条形指示器
  • index:数字索引(如 1/5)
  • title:文字标题模式
  • fraction:分式指示器(如 1/5) 通过 total 属性设置指示点总数或者使用 list 属性设置指示文本
    <view style="position: relative">
    <swiper style="height: 300rpx" :current="current" @change="onChange" :autoplay="true" :interval="3000">
        <swiper-item class="slide slide1"><text class="text">1</text></swiper-item>
        <swiper-item class="slide slide2"><text class="text">2</text></swiper-item>
        <swiper-item class="slide slide3"><text class="text">3</text></swiper-item>
    </swiper>
    <l-swiper-dot :current="current" type="dot" :total="3" />
    </view>
    const current = ref(0)
    const type = ref('dot')
    const onChange = (e: UniSwiperChangeEvent) => {
    current.value = e.detail.current
    }

自定义颜色

使用 color可设置文本颜色, activeColor可设置激活状态指示点颜色,inactiveColor默认背景色

<view style="position: relative">
    <swiper style="height: 300rpx" :current="current" @change="onChange" :autoplay="true" :interval="3000">
        <swiper-item class="slide slide1"><text class="text">1</text></swiper-item>
        <swiper-item class="slide slide2"><text class="text">2</text></swiper-item>
        <swiper-item class="slide slide3"><text class="text">3</text></swiper-item>
    </swiper>
    <l-swiper-dot  activeColor="#ff6b6b" inactiveColor="#ffe66d" color="#2d3436"  :current="current" type="title" :list="list" field="title" />
</view>
const current = ref(0)
const type = ref('dot')
const onChange = (e: UniSwiperChangeEvent) => {
    current.value = e.detail.current
}
const list = [
    {
        title: '人生得意须尽欢,莫使金樽空对月。天生我材必有用,千金散尽还复来。',
    },
    {
        title: '但愿人长久,千里共婵娟。',
    },
    {
        title: '无边落木萧萧下,不尽长江滚滚来。万里悲秋常作客,百年多病独登台。',
    },
]

查看示例

  • 导入后直接使用这个标签查看演示效果
<!-- // 代码位于 uni_modules/lime-swiper-dot/compoents/lime-swiper-dot -->
<lime-swiper-dot />

插件标签

  • 默认 l-swiper-dot 为 component
  • 默认 lime-swiper-dot 为 demo

关于vue2的使用方式

  • 插件使用了composition-api, 如果你希望在vue2中使用请按官方的教程vue-composition-api配置
  • 关键代码是: 在main.js中 在vue2部分加上这一段即可
    // vue2
    import Vue from 'vue'
    import VueCompositionAPI from '@vue/composition-api'
    Vue.use(VueCompositionAPI)

API

Props

参数 说明 类型 必填 默认值
type 指示器类型,可选值:dot dot-bar index title fraction String -
total 轮播项总数(非title类型时使用) Number -
current 当前激活项索引(从0开始) Number -
field 标题类型时使用的数据字段名(仅type="title"时生效) String -
list 数据源数组(title类型必需,其他类型可选) Array []
color 全局文本颜色(影响所有文字) String -
activeColor 激活态指示器颜色 String -
inactiveColor 未激活态指示器颜色 String -
fontSize 文字字号(带单位) String -

主题定制

样式变量

组件提供了下列 CSS 变量,可用于自定义样式,uvue app不支持。

名称 默认值 描述
--l-swiper-dot-fraction-right $spacer-sm 分式指示器右侧定位偏移量
--l-swiper-dot-fraction-bottom $spacer-sm 分式指示器底部定位偏移量
--l-swiper-dot-fraction-padding $spacer-tn $spacer-xs 分式指示器内边距
--l-swiper-dot-title-padding $spacer-xs $spacer-xs 标题类型指示器内边距
--l-swiper-dot-radius $border-radius-hg 指示器圆角半径
--l-swiper-dot-text-color white 指示器文字颜色
--l-swiper-dot-bg-color rgba(0,0,0,0.3) 指示器默认背景色
--l-swiper-dot-active-bg-color rgba(0,0,0,0.5) 激活状态指示器背景色
--l-swiper-dot-font-size $font-size 指示器文字基准字号
--l-swiper-dot-line-height $line-height 指示器文字行高
--l-swiper-dot-index-size 40rpx 数字索引指示器尺寸
--l-swiper-dot-gap 5rpx 指示点之间的间隔
--l-swiper-dot-size 12rpx 常规指示点尺寸
--l-swiper-dot-active-size 24rpx 激活状态指示点尺寸

打赏

如果你觉得本插件,解决了你的问题,赠人玫瑰,手留余香。

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问