Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(indexes): 索引导航无法选中问题 #2036

Merged
merged 4 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/indexes/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

name | type | default | description | required
-- | -- | -- | -- | --
async | Boolean | false | 是否异步数据 | N
index-list | Array | - | `0.32.0`。Typescript:`string [] \| number[]` | N
list | Array | [] | `deprecated`。Typescript:`ListItem[] ` `interface ListItem { title: string; index: string; children: { title: string; [key: string]: any} [] }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/indexes/type.ts) | N
sticky | Boolean | true | Typescript:`Boolean` | N
Expand Down
1 change: 1 addition & 0 deletions src/indexes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ isComponent: true

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
async | Boolean | false | 是否异步数据 | N
index-list | Array | - | `0.32.0`。索引字符列表。不传默认 `A-Z`。TS 类型:`string [] \| number[]` | N
list | Array | [] | 已废弃。索引列表的列表数据。每个元素包含三个子元素,index(string):索引值,例如1,2,3,...或A,B,C等;title(string): 索引标题,可不填将默认设为索引值;children(Array<{title: string}>): 子元素列表,title为子元素的展示文案。。TS 类型:`ListItem[] ` `interface ListItem { title: string; index: string; children: { title: string; [key: string]: any} [] }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/indexes/type.ts) | N
sticky | Boolean | true | 索引是否吸顶,默认为true。TS 类型:`Boolean` | N
Expand Down
3 changes: 2 additions & 1 deletion src/indexes/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class Indexes extends SuperComponent {
observers = {
indexList(v) {
this.setIndexList(v);
this.setHeight(this.data._height);
},
height(v) {
this.setHeight(v);
Expand All @@ -55,7 +56,7 @@ export default class Indexes extends SuperComponent {
if (this.data._height === 0) {
this.setHeight();
}
if (this.data._indexList?.length === 0) {
if (this.data._indexList?.length === 0 && !this.data.async) {
this.setIndexList();
}
},
Expand Down
5 changes: 5 additions & 0 deletions src/indexes/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

import { TdIndexesProps } from './type';
const props: TdIndexesProps = {
/** 是否异步数据 */
async: {
type: Boolean,
value: false,
},
/** 索引字符列表。不传默认 `A-Z` */
indexList: {
type: Array,
Expand Down
8 changes: 8 additions & 0 deletions src/indexes/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
* */

export interface TdIndexesProps {
/**
* 是否异步数据
* @default false
*/
async?: {
type: BooleanConstructor;
value?: boolean;
};
/**
* 自定义组件样式
* @default ''
Expand Down