更新记录

0.0.2(2023-07-21)

  • chore: 去掉 type
  • fix: 修复 anchor 在sticky下没对齐父级

0.0.1(2023-07-17)

  • 首次上传,可能存在BUG

平台兼容性

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

lime-indexes 索引栏

  • 用于列表的索引分类显示和快速定位。

代码演示

基础用法

点击索引栏时,会自动跳转到对应的 IndexesAnchor 锚点位置。

<l-indexes>
    <l-indexes-anchor index="A" />
    <view>文本</view>
    <view>文本</view>
    <view>文本</view>
    <l-indexes-anchor index="B" />
    <view>文本</view>
    <view>文本</view>
    <view>文本</view>
  ...
</l-indexes>

自定义索引列表

可以通过 index-list 属性自定义展示的索引字符列表。

<l-indexes :index-list="indexList">
  <l-indexes-anchor index="1">标题1</l-indexes-anchor>
  <view class="cell">文本</view>
  <view class="cell">文本</view>
  <view class="cell">文本</view>

  <l-indexes-anchor index="2">标题2</l-indexes-anchor>
  <view class="cell">文本</view>
  <view class="cell">文本</view>
  <view class="cell">文本</view>

  ...
</l-indexes>
export default {
  setup() {
    return {
      indexList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    };
  },
};

查看示例

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

插件标签

  • 默认 l-indexes 为 component
  • 默认 l-indexes-anchor 为 component
  • 默认 lime-indexes 为 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

Indexes Props

参数 说明 类型 默认值
index-list 索引字符列表 (string | number)[] A-Z
z-index z-index 层级 number | string 1
sticky 是否开启锚点自动吸顶 boolean true
sticky-offset 锚点自动吸顶时与顶部的距离 number 0
scroll-view 是否使用 scrollView 滚动,默认是页面 boolean false

IndexesAnchor Props

参数 说明 类型 默认值
index 索引字符 number | string -

Indexes Events

事件名 说明 回调参数
select 点击索引栏的字符时触发 index: number | string
change 当前高亮的索引字符变化时触发 index: number | string

Indexes 方法

通过 ref 可以获取到 Indexes 实例并调用实例方法。

方法名 说明 参数 返回值
scrollTo 滚动到指定锚点 index: number | string -

IndexesAnchor Slots

名称 说明
default 锚点位置显示内容,默认为索引字符

主题定制

样式变量

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

名称 默认值 描述
--l-indexes-sidebar-active-bg-color #1677ff -
--l-indexes-sidebar-active-color white -
--l-indexes-sidebar-color rgba(0,0,0,0.9) -
--l-indexes-sidebar-font-size 12px -
--l-indexes-sidebar-item-size 20px -
--l-indexes-sidebar-line-height 20px -
--l-indexes-sidebar-right 8px -
--l-indexes-sidebar-tips-bg-color rgba(#1677ff, 0.15) -
--l-indexes-sidebar-tips-color #1677ff -
--l-indexes-sidebar-tips-font-size 20px -
--l-indexes-sidebar-tips-right 38px -
--l-indexes-sidebar-tips-size 48px -
--l-indexes-anchor-active-bg-color white -
--l-indexes-anchor-active-color #1677ff -
--l-indexes-anchor-active-font-weight 600 -
--l-indexes-anchor-bg-color #f5f5f5 -
--l-indexes-anchor-color rgba(0,0,0,0.9) -
--l-indexes-anchor-font-size 14px -
--l-indexes-anchor-line-height 22px -
--l-indexes-anchor-padding 4px 16px -

常见问题

  • 父级有设置transform会导致 fixed 失效

隐私、权限声明

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

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

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

许可协议

MIT协议

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