Skip to content
官方QQ交流群
pc端ui:468705115   点此加入
移动端ui:468217742   点此加入
技术交流1:87208295   点此加入
技术交流2:787747122   点此加入
官网
云控制台
开放平台
关注微信公众号
代码仓库: 码云

IndexList 索引列表

通过折叠面板收纳内容区域

平台差异说明

App(vue)App(nvue)H5小程序

基本使用

外层包裹一个index-list组件,锚点通过index-anchor组件传入,自定义列表内容通过index-item嵌套使用

  • nvue需要将index-anchor写在index-item的外部
  • 非nvue需要将index-anchor嵌套在index-item的内部
  • 可以通过index-list参数自定义索引字符列表
  • 需要监听页面的onPageScroll事件,将当前滚动条高度传入index-list组件
html
<template>
	<up-index-list :index-list="indexList">
		<template v-for="(item, index) in itemArr">
			<!-- #ifdef APP-NVUE -->
			<up-index-anchor :text="indexList[index]"></up-index-anchor>
			<!-- #endif -->
			<up-index-item>
				<!-- #ifndef APP-NVUE -->
				<up-index-anchor :text="indexList[index]"></up-index-anchor>
				<!-- #endif -->
				<view class="list-cell" v-for="(cell, index) in item">
					{{cell}}
				</view>
			</up-index-item>
		</template>
	</up-index-list>
</template>

<script>
	export default {
		data() {
			return {
				indexList: ["A", "B", "C"],
				itemArr: [
					['列表A1','列表A2','列表A3'],
					['列表B1','列表B2','列表B3'],
					['列表C1','列表C2','列表C3']
				]
			}
		}
	}
</script>

<style scoped>
.list-cell {
  display: flex;
  box-sizing: border-box;
  width: 100%;
  padding: 10px 24rpx;
  overflow: hidden;
  color: #323233;
  font-size: 14px;
  line-height: 24px;
  background-color: #fff;
}
</style>

自定义导航栏

默认情况下,组件的锚点是吸附在导航栏下方的,如果您修改了导航栏,比如取消导航栏、或者自定义了导航栏,就需要指定吸顶的高度,也就是custom-nav-height 的值,注意这个值的单位为px

  • 如果自定义了导航栏,需要custom-nav-height设置为导航栏的高度

此页面源代码地址

页面源码地址


 github  gitee

API

IndexBar Props

参数说明类型默认值可选值
inactiveColor右边锚点状态非激活时的颜色String#606266-
activeColor右边锚点状态激活时的颜色String#5677fc-
indexList索引字符列表,数组Array[string/number]A-Z-
sticky是否开启锚点自动吸顶Booleantruefalse
customNavHeight自定义导航栏的高度,单位默认pxString/Number0-

IndexAnchor Props

参数说明类型默认值可选值
text列表锚点文本内容String/Number--
color列表锚点文字颜色String#606266-
size列表锚点文字大小,单位默认pxString/Number14-
bgColor列表锚点背景颜色String#dedede-
height列表锚点高度,单位默认pxString/Number32-

IndexBar Events

事件名说明回调参数版本
select选中右边索引字符时触发index: 索引字符-

IndexItem Slots

名称说明
default自定义列表内容

Copyright © 2017 10yun.com | 十云提供计算服务-IPV6 | ctocode组开发