更新记录
0.0.6(2025-09-27)
- fix: 修复uniapp vue2 微信小程序报错
0.0.5(2025-09-27)
- fix: 优化条件编译
0.0.4(2025-06-12)
- fix: 修复uniappx微信小程序报错问题
平台兼容性
uni-app(4.53)
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | √ | - | 5.1 | √ | √ |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
√ | - | - | - | - | - | - | - | - | - | - |
uni-app x(4.61)
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
√ | √ | 5.1 | √ | √ | √ |
lime-fit-swiper 自适应高度轮播
仿淘宝金刚区滚动切换高度的轮播组件,可以根据内容自动调整高度,实现平滑过渡效果。组件支持自定义指示器,适用于需要根据内容高度自动调整的轮播场景。
插件依赖:
lime-shared
、lime-style
文档链接
📚 组件详细文档请访问以下站点:
安装方法
- 在uni-app插件市场中搜索并导入
lime-fit-swiper
- 导入后可能需要重新编译项目
- 在页面中使用
l-fit-swiper
组件和l-fit-swiper-item
代码演示
基础用法
通过data属性传入数据,并使用group插槽自定义内容。
<l-fit-swiper :data="list">
<template #group="{group}">
<view class="grid">
<view class="grid-item" v-for="item in group">
<image class="grid-item-image" :src="item.icon" mode="widthFix"></image>
<text class="grid-item-text">{{item.name}}</text>
</view>
</view>
</template>
</l-fit-swiper>
const list = ref([
[
{
icon: 'https://example.com/icon1.png',
name: '选项1'
},
{
icon: 'https://example.com/icon2.png',
name: '选项2'
},
// 更多选项...
],
[
{
icon: 'https://example.com/icon3.png',
name: '选项3'
},
{
icon: 'https://example.com/icon4.png',
name: '选项4'
},
// 更多选项...
]
])
自定义指示器
自定义导航指示器的样式和位置。
<l-fit-swiper
indicatorColor="#cccccc"
indicatorActiveColor="#ff0000"
:data="indicatorList">
...
</l-fit-swiper>
const indicatorList = ref([
{ content: '第一页内容' },
{ content: '第二页内容' },
{ content: '第三页内容' }
])
快速预览
导入插件后,可以直接使用以下标签查看演示效果:
<!-- 代码位于 uni_modules/lime-fit-swiper/components/lime-fit-swiper -->
<lime-fit-swiper />
插件标签说明
标签名 | 说明 |
---|---|
l-fit-swiper |
组件标签 |
l-fit-swiper-item |
轮播项标签 |
lime-fit-swiper |
演示标签 |
API文档
Props 属性说明
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
data | 轮播数据源 | Array | [] |
current | 当前所在滑块的索引 | number | 0 |
indicatorDots | 是否显示导航指示器 | boolean | true |
indicatorWidth | 导航指示器每项的宽度 | string | - |
indicatorHeight | 导航指示器高度 | string | - |
indicatorColor | 导航指示器颜色 | string | - |
indicatorActiveColor | 导航指示器激活颜色 | string | - |
lClass | 自定义类名 | string | - |
Events 事件
事件名 | 说明 | 回调参数 |
---|---|---|
change | 轮播切换时触发 | index: number |
Slots 插槽
名称 | 说明 |
---|---|
default | 默认插槽,用于直接插入l-fit-swiper-item,仅WEB,APP生效 |
group | 分组数据渲染插槽,当使用data属性时可用 |
自定义主题
组件提供了以下CSS变量,可用于自定义样式:
变量名称 | 默认值 | 描述 |
---|---|---|
--l-fit-swiper-indicator-height |
4px |
指示器高度 |
--l-fit-swiper-indicator-item-width |
12px |
指示器项宽度 |
--l-fit-swiper-indicator-item-radius |
6px |
指示器项圆角 |
--l-fit-swiper-indicator-gap |
2px |
指示器项间距 |
--l-fit-swiper-indicator-bottom |
10px |
指示器底部距离 |
--l-fit-swiper-padding-bottom |
20px |
轮播底部内边距 |
--l-fit-swiper-indicator-color |
$gray-3 |
指示器颜色 |
--l-fit-swiper-indicator-active-color |
$primary-color |
指示器激活颜色 |
Vue2使用说明
main.js中添加以下代码:
// vue2项目中使用
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)
详细配置请参考官方文档:Vue Composition API
支持与赞赏
如果你觉得本插件解决了你的问题,可以考虑支持作者:
支付宝赞助 | 微信赞助 |
---|---|
![]() |
![]() |