注册 X
提交 注:点击提交后系统会发送邮件到邮箱验证!(仅支持中国大陆邮箱)
我已阅读并同意 服务条款
首页 > IT技术笔记 > 查看笔记

vant-IndexBar 索引栏

引入

        
        
      

代码演示

基础用法

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

        
        
      

自定义索引列表

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

        
        
      

        
        
      

API

IndexBar Props

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

IndexAnchor Props

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

IndexBar Events

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

IndexAnchor Slots

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

IndexBar 方法

通过 ref 可以获取到 IndexBar 实例并调用实例方法,详见

组件实例方法

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

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考

主题定制

名称默认值描述
@index-bar-sidebar-z-index2-
@index-bar-index-font-size@font-size-xs-
@index-bar-index-line-height@line-height-xs-
@index-bar-index-active-color@red-
@index-anchor-z-index1-
@index-anchor-padding0 @padding-md-
@index-anchor-text-color@text-color-
@index-anchor-font-weight@font-weight-bold-
@index-anchor-font-size@font-size-md-
@index-anchor-line-height32px-
@index-anchor-background-colortransparent-
@index-anchor-sticky-text-color@red-
@index-anchor-sticky-background-color@white-


效果图:


 打赏        分享



评论

邮箱: 昵称: