ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

Tree组件tree-data属性的TS类型错误

Open UlyssesChou opened this issue 1 year ago • 5 comments
trafficstars

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Version

4.1.0

Environment

antd 4.1.0

Reproduction link

http://demo

Steps to reproduce

<a-tree
:checkable="true"
:fieldNames="replaceFields"
:tree-data="permissionList"
:default-expand-all="true"
:checkStrictly="true"
v-model:checkedKeys="checkedKeys"
/>

tree组件中,我得结果集是permissionList,同时搭配fieldNames一起使用,IDE编译器提示TS类型【DataNode[]】不一致。我看DataNode的key目前是不能为空。

export interface DataNode extends BasicDataNode {
children?: DataNode[];
key: string | number;
title?: any;
}

What is expected?

export interface DataNode extends BasicDataNode {
children?: DataNode[];
key?: string | number;
title?: any;
}

What is actually happening?

export interface DataNode extends BasicDataNode {
children?: DataNode[];
key: string | number;
title?: any;
}

UlyssesChou avatar Mar 06 '24 03:03 UlyssesChou

image 这样使用试下

selicens avatar Mar 06 '24 05:03 selicens

TreeData对象类型,里面的变量'key'是不能为空的,treedata这样子定义当前代码IDE也会提示,使用filed-name的不就是用来用自定义字段代替'key'吗

UlyssesChou avatar Mar 06 '24 05:03 UlyssesChou

确实

selicens avatar Mar 06 '24 07:03 selicens

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar May 06 '24 02:05 github-actions[bot]

我想控制tree树状控件某些节点根据一个响应式来判断css隐藏或者显;但是tree的api似乎没有提供这个 然后我使用default插槽;提示报错 image

AlexL0ng avatar May 10 '24 10:05 AlexL0ng

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Jul 10 '24 02:07 github-actions[bot]