vant/src/index-bar
neverland c13b953cff
feat(IndexBar): add change event (#7296)
* feat(IndexBar): add change event

* docs(IndexBar): update event param
2020-10-08 18:56:21 +08:00
..
2020-07-31 19:07:20 +08:00

IndexBar

Install

import Vue from 'vue';
import { IndexBar } from 'vant';

Vue.use(IndexBar);
Vue.use(IndexAnchor);

Usage

Basic Usage

<van-index-bar>
  <van-index-anchor index="A" />
  <van-cell title="Text" />
  <van-cell title="Text" />
  <van-cell title="Text" />

  <van-index-anchor index="B" />
  <van-cell title="Text" />
  <van-cell title="Text" />
  <van-cell title="Text" />

  ...
</van-index-bar>

Custom Index List

<van-index-bar :index-list="indexList">
  <van-index-anchor index="1">Title 1</van-index-anchor>
  <van-cell title="Text" />
  <van-cell title="Text" />
  <van-cell title="Text" />

  <van-index-anchor index="2">Title 2</van-index-anchor>
  <van-cell title="Text" />
  <van-cell title="Text" />
  <van-cell title="Text" />

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

API

IndexBar Props

Attribute Description Type Default
index-list Index List string[] | number[] A-Z
z-index z-index number | string 1
sticky Whether to enable anchor sticky top boolean true
sticky-offset-top Anchor offset top when sticky number 0
highlight-color Index character highlight color string #07c160

IndexAnchor Props

Attribute Description Type Default
index Index number | string -

IndexBar Events

Event Description Arguments
select Triggered when select index index: number | string
change v2.10.10 Triggered when active index changed index: number | string

IndexAnchor Slots

Name Description
default Anchor content, show index by default