更新记录
0.1.1(2025-12-09)
0.1.0(2025-11-15)
- fix: 修复uniapp缺少name的变量导致无法获取尺寸
0.0.9(2025-08-31)
查看更多
平台兼容性
uni-app(4.75)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| √ |
√ |
√ |
√ |
√ |
- |
5.0 |
√ |
√ |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
| √ |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(4.74)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| √ |
√ |
5.0 |
√ |
√ |
√ |
其他
lime-indexes 索引组件
一个功能丰富的索引组件,用于快速导航和定位内容。支持吸顶效果、自定义颜色和主题等多种配置,可用于通讯录、城市选择等场景。组件提供了丰富的自定义选项,可以满足各种复杂的界面设计需求。索引字符自动从子组件中收集,无需手动配置。
插件依赖:lime-shared、lime-style
文档链接
📚 组件详细文档请访问以下站点:
安装方法
- 在uni-app插件市场中搜索并导入
lime-indexes
- 导入后重新编译项目
- 在页面中按需引入并使用相关组件
代码演示
基础用法
使用l-indexes和相关子组件创建完整的索引列表,索引会自动从l-indexes-section的index属性收集。所有平台都支持此用法。以下是非循环方式的显式示例,更直观地展示组件结构:
<l-indexes :showTips="true">
<!-- A组 -->
<l-indexes-section index="A">
<view class="index-item">
<view class="index-item-info">
<text class="index-item-name">阿坝</text>
<text class="index-item-desc">513200</text>
</view>
</view>
<view class="index-item">
<view class="index-item-info">
<text class="index-item-name">阿拉善</text>
<text class="index-item-desc">152900</text>
</view>
</view>
</l-indexes-section>
<!-- B组 -->
<l-indexes-section index="B">
<view class="index-item">
<view class="index-item-info">
<text class="index-item-name">北京</text>
<text class="index-item-desc">110000</text>
</view>
</view>
<view class="index-item">
<view class="index-item-info">
<text class="index-item-name">保定</text>
<text class="index-item-desc">130600</text>
</view>
</view>
</l-indexes-section>
</l-indexes>
说明:
- 每个
l-indexes-section代表一个索引分组,index属性指定分组的索引字符
- 在实际项目中,可以根据需要选择循环方式或显式方式
ScrollView 容器
在需要局部使用索引组件的场景中,设置scrollView属性为true并指定组件高度。
<l-indexes scroll-view style="height: 500px">
<!-- 内容结构 -->
</l-indexes>
标记式
使用 anchor 标记式需要根据平台条件编译的使用,它节点最少性能应该最好。在uniappx APP平台使用sticky-section和list-item组件获得更好的性能。
<l-indexes :showTips="true">
<!-- #ifdef APP-ANDROID || APP-IOS -->
<sticky-section v-for="item in list" :key="item.index">
<l-indexes-anchor :index="item.index" />
<list-item class="platform-item" v-for="(val, i) in item.children" :key="i">
<image class="platform-item-avatar" :src="'https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/avatar-' + (i % 5 + 1) + '.png'"></image>
<text class="platform-item-title">{{val.name}}</text>
</list-item>
</sticky-section>
<!-- #endif -->
<!-- #ifndef APP-ANDROID || APP-IOS -->
<template v-for="item in list" :key="item.index">
<l-indexes-anchor :index="item.index" />
<view class="platform-item" v-for="(val, i) in item.children" :key="i">
<text class="platform-item-title">{{val.name}}</text>
</view>
</template>
<!-- #endif -->
</l-indexes>
快速预览
导入插件后,可以直接使用以下标签查看演示效果:
<!-- 代码位于 uni_modules/lime-indexes/components/l-indexes -->
<l-indexes />
组件说明
| 组件名 |
说明 |
l-indexes |
主索引组件,提供侧边栏索引和滚动定位功能 |
l-indexes-section |
带吸顶效果的锚点区域组件,用于显示索引标题和内容 |
l-indexes-anchor |
锚点组件,用于标记索引位置 |
l-indexes-view |
平台适配组件,在不同平台上提供适当的渲染方式 |
Vue2使用说明
main.js中添加以下代码:
// vue2项目中使用
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)
详细配置请参考官方文档:Vue Composition API
API文档
l-indexes Props 属性说明
| 属性名 |
说明 |
类型 |
默认值 |
| sticky |
索引是否吸顶 |
boolean |
true |
| stickyOffset |
锚点吸顶时与顶部的距离 |
number |
0 |
| zIndex |
层级 |
number |
1 |
| scrollView |
是否使用滚动视图 |
boolean |
false |
| showTips |
是否显示选中索引提示 |
boolean |
false |
| color |
索引字符颜色 |
string |
- |
| activeColor |
索引激活状态颜色 |
string |
- |
| activeBgColor |
索引激活状态背景色 |
string |
- |
| tipsColor |
提示文字颜色 |
string |
- |
| tipsBgColor |
提示背景色 |
string |
- |
| current |
当前选中的索引 |
string |
- |
| reset |
是否重置选中状态(废除) |
boolean |
false |
l-indexes Events 事件
| 事件名 |
说明 |
回调参数 |
| select |
点击索引时触发 |
index: number |
| change |
滚动时触发或索引变化时触发 |
name: string |
| update:current |
当前索引更新事件 |
name: string |
l-indexes-section Props 属性说明
| 属性名 |
说明 |
类型 |
默认值 |
| index |
锚点索引字符 |
string |
- |
| items |
子项列表数据 |
any[] |
- |
l-indexes-section Slots 插槽
| 名称 |
说明 |
| default |
自定义内容 |
| header |
自定义头部内容 |
| item |
自定义子项内容,参数为 {item, index} |
l-indexes-anchor Props 属性说明
| 属性名 |
说明 |
类型 |
默认值 |
| index |
锚点索引字符 |
string |
- |
l-indexes-anchor Slots 插槽
l-indexes-view Slots 插槽
主题定制
组件提供了以下CSS变量,可用于自定义样式:
| 变量名称 |
默认值 |
描述 |
--l-indexes-sidebar-color |
$text-color-1 |
索引颜色 |
--l-indexes-sidebar-item-size |
20px |
索引项大小 |
--l-indexes-sidebar-font-size |
12px |
索引字体大小 |
--l-indexes-sidebar-line-height |
20px |
索引行高 |
--l-indexes-sidebar-active-color |
white |
激活状态颜色 |
--l-indexes-sidebar-active-bg-color |
$primary-color |
激活状态背景色 |
--l-indexes-sidebar-right |
8px |
索引右侧距离 |
--l-indexes-sidebar-padding |
15px |
索引内边距 |
--l-indexes-sidebar-tips-size |
48px |
提示大小 |
--l-indexes-sidebar-tips-font-size |
20px |
提示字体大小 |
--l-indexes-sidebar-tips-color |
$primary-color |
提示颜色 |
--l-indexes-sidebar-tips-bg-color |
$primary-color-1 |
提示背景色 |
--l-indexes-sidebar-tips-right |
38px |
提示右侧距离 |
--l-indexes-anchor-color |
$text-color-1 |
锚点颜色 |
--l-indexes-anchor-active-bg-color |
$bg-color-container |
激活状态描边色 |
--l-indexes-anchor-active-color |
$primary-color |
激活状态颜色 |
--l-indexes-anchor-active-border-color |
$primary-color |
激活状态颜色 |
--l-indexes-anchor-bg-color |
$gray-2 |
锚点背景色 |
--l-indexes-anchor-font-size |
14px |
锚点字体大小 |
--l-indexes-anchor-line-height |
22px |
锚点行高 |
--l-indexes-anchor-active-font-weight |
700 |
激活状态字体粗细 |
--l-indexes-anchor-padding-x |
16px |
水平内边距 |
--l-indexes-anchor-padding-y |
4px |
垂直内边距 |
支持与赞赏
如果本组件对你有帮助,欢迎支持作者:
| 支付宝赞助 |
微信赞助 |
 |
 |