Skip to content

IndexBar 索引栏

介绍

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

引入

js
import { createApp } from 'vue';
import { IndexAnchor, IndexBar } from '@szhn/dh-design-mobile';

const app = createApp();
app.use(IndexAnchor);
app.use(IndexBar);

代码演示

基础用法

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

html
<van-index-bar>
  <template v-for="char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" :key="char">
    <van-index-anchor :index="char" />
    <van-cell :title="'文本 ' + char" />
    <van-cell :title="'文本 ' + char" />
    <van-cell :title="'文本 ' + char" />
  </template>
</van-index-bar>

API

IndexBar Props

参数说明类型默认值
index-list索引字符列表string[] | number[]A-Z
z-indexz-index 层级number | string1
sticky是否开启锚点自动吸顶booleantrue
sticky-offset-top锚点自动吸顶时与顶部的距离number0
highlight-color索引字符高亮颜色string#1989fa
teleport索引栏的传送目标节点string | Element-

IndexAnchor Props

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