/*! For license information please see 7681.8705a4c4.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["7681"],{64400:function(n,s,a){"use strict";a.r(s);var t=a("80681");let e=["innerHTML"];s.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
Used for indexed sorting display and quick positioning of lists.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { IndexBar } from 'vant';\n\nconst app = createApp();\napp.use(IndexBar);\napp.use(IndexAnchor);\n
\n<van-index-bar>\n <van-index-anchor index="A" />\n <van-cell title="Text" />\n <van-cell title="Text" />\n <van-cell title="Text" />\n\n <van-index-anchor index="B" />\n <van-cell title="Text" />\n <van-cell title="Text" />\n <van-cell title="Text" />\n\n ...\n</van-index-bar>\n
\n<van-index-bar :index-list="indexList">\n <van-index-anchor index="1">Title 1</van-index-anchor>\n <van-cell title="Text" />\n <van-cell title="Text" />\n <van-cell title="Text" />\n\n <van-index-anchor index="2">Title 2</van-index-anchor>\n <van-cell title="Text" />\n <van-cell title="Text" />\n <van-cell title="Text" />\n\n ...\n</van-index-bar>\n
\nexport default {\n setup() {\n return {\n indexList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],\n };\n },\n};\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
index-list | \nIndex List | \n(string | number)[] | \nA-Z | \n
z-index | \nz-index | \nnumber | string | \n1 | \n
sticky | \nWhether to enable anchor sticky top | \nboolean | \ntrue | \n
sticky-offset-top | \nAnchor offset top when sticky | \nnumber | \n0 | \n
highlight-color | \nIndex character highlight color | \nstring | \n#1989fa | \n
teleport | \nSpecifies a target element where IndexBar will be mounted | \nstring | Element | \n- | \n
Attribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
index | \nIndex | \nnumber | string | \n- | \n
Event | \nDescription | \nArguments | \n
---|---|---|
select | \nEmitted when an index is selected | \nindex: number | string | \n
change | \nEmitted when active index changed | \nindex: number | string | \n
Use ref to get IndexBar instance and call instance methods.
\nName | \nDescription | \nAttribute | \nReturn value | \n
---|---|---|---|
scrollTo | \nscroll to target element | \nindex: number | string | \n- | \n
The component exports the following type definitions:
\nimport type { IndexBarProps, IndexAnchorProps, IndexBarInstance } from 'vant';\n
\nIndexBarInstance
is the type of component instance:
import { ref } from 'vue';\nimport type { IndexBarInstance } from 'vant';\n\nconst indexBarRef = ref<IndexBarInstance>();\n\nindexBarRef.value?.scrollTo('B');\n
\nName | \nDescription | \n
---|---|
default | \nAnchor content, show index by default | \n
The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-index-bar-sidebar-z-index | \n2 | \n- | \n
--van-index-bar-index-font-size | \nvar(--van-font-size-xs) | \n- | \n
--van-index-bar-index-line-height | \nvar(--van-line-height-xs) | \n- | \n
--van-index-bar-index-active-color | \nvar(--van-primary-color) | \n- | \n
--van-index-anchor-z-index | \n1 | \n- | \n
--van-index-anchor-padding | \n0 var(--van-padding-md) | \n- | \n
--van-index-anchor-text-color | \nvar(--van-text-color) | \n- | \n
--van-index-anchor-font-weight | \nvar(--van-font-bold) | \n- | \n
--van-index-anchor-font-size | \nvar(--van-font-size-md) | \n- | \n
--van-index-anchor-line-height | \n32px | \n- | \n
--van-index-anchor-background | \ntransparent | \n- | \n
--van-index-anchor-sticky-text-color | \nvar(--van-primary-color) | \n- | \n
--van-index-anchor-sticky-background | \nvar(--van-background-2) | \n- | \n