# t-indexed
Indexed 索引列表
t-indexed 组件介绍
索引导航组件,用于显示索引列表,支持配置索引数据列表,通过Canvas绘制实现高性能渲染。
t-indexed 平台兼容
| Harmony | H5 | Android | iOS | 小程序 | UTS |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
t-indexed 基础用法
基础用法参考 demo/indexed/indexed.uvue,通过 Canvas 绘制实现高性能渲染。
vue
<template>
<view class='f'>
<tui-theme-switch></tui-theme-switch>
<t-indexed class="f"
type="error"
:list="dataList"
@select="select"></t-indexed>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { TuiApi } from '@/api'
import { onMounted } from 'vue'
const dataList = ref<UTSJSONObject[]>([])
onMounted(() => {
TuiApi('indexsortdata', {}, true).then((res : UTSJSONObject) => {
dataList.value = res.getArray<UTSJSONObject>('data')!
})
})
const select = (e : UTSJSONObject) => {
if (e.getString('letter') != null) {
uni.showToast({
title: e.getString('letter')!
})
} else {
uni.showToast({
title: e.getString('name')!
})
}
console.log(e)
}
</script>t-indexed Props
| 属性名 | 类型 | 默认值 | 说明 | 可选值 |
|---|---|---|---|---|
| size | String | "medium" | 组件尺寸 | large, medium, small, mini |
| type | String | "primary" | 组件类型 | info, primary, error, warning, success |
| disabled | Boolean | false | 组件是否禁用 | true, false |
| hover | Boolean | false | 是否有点击效果 | true, false |
| path | String | "" | 点击组件后跳转的页面路径 | - |
| effect | String | "normal" | 组件显示主题 | normal, dark, light, plain |
| list | Array | [] | 数据源 | - |
t-indexed Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| select | 索引选中时触发 | 当前选中的信息 |
| click | 点击时触发 | - |
| transitionend | 动画结束时触发 | - |
| initFinished | 组件初始化完成触发 | 组件的节点信息 |
| touchstart | 触摸开始时触发 | 触摸事件对象 |
| touchend | 触摸结束时触发 | 触摸事件对象 |
| touchmove | 触摸移动时触发 | 触摸事件对象 |
| touchcancel | 触摸取消时触发 | 触摸事件对象 |
数据结构
| 字段名 | 类型 | 说明 |
|---|---|---|
| id | String | 列表项的唯一标识 |
| name | String | 列表项的显示名称 |
| letter | String | 索引字母,用于分组显示 |