ant-design-vue&设置treeDataSimpleMode属性不生效的问题&及其解决方案

环境

  1. ant-design-vue 版本 1.7.8
  2. 使用官方的树形组件api
  3. 添加treeDataSimpleMode属性,一直未出现效果

需要实现的的效果

  1. 想要达成树结构的展示(如下图,可以点击节点展示子节点)

在这里插入图片描述

2.实际的效果(不是节点展示,而是数据平铺)
在这里插入图片描述
我的代码

          <a-directory-tree
            multiple treeDataSimpleMode
            :treeData="treeData"
            :replaceFields="ModeData"
            @select="onSelect"
            @expand="onExpand"
          >
          </a-directory-tree>

<script>
    return {
      treeDataSimpleMode:{ id: 'id', pId: 'pId', rootPId: 0 },
      ModeData: { children: "Node", title: "Name", key: "index"},
      treeData: [
  { id:1,Name: "我的文档", type: "floder", index: "abc",pId:0},
  { id:2,Name: "图片", type: "floder", index: "abc1",pId:1},
  { id:3,Name: "文件", type: "floder", index: "abc2",pId:1}    ],
    };
</script>

发现的问题

  1. treeDataSimpleMode只对 <‘a-tree-select’> html标签生效,我使用的是<“a-directory-tree”>。测了很久都没生效,重新阅读了一下结果是这样的原因
  2. 通俗讲,就是看看标签选对没有

其他解决方法

1.可以通过修改数据格式,将集合数据转换为树节点数据结构

//递归算法测试

/**
 * List集合--树形结构-数据转换
 */


var list = [
    { id: 1, pId: 0, value: '1', title: 'Expand to load' },
    { id: 2, pId: 1, value: '2', title: 'Expand to load' },
    { id: 3, pId: 1, value: '3', title: 'Tree Node', isLeaf: true },
    { id: 4, pId: 2, value: '3', title: 'Tree Node', isLeaf: true },
    { id: 5, pId: 2, value: '3', title: 'Tree Node', isLeaf: true },
    { id: 6, pId: 3, value: '3', title: 'Tree Node', isLeaf: true },
    { id: 7, pId: 3, value: '3', title: 'Tree Node', isLeaf: true },
]



var TreeFuction = function (list, pid) {
    var tree = []
    for (let i = 0; i < list.length; i++) {
        var aaa = list[i];

        if (aaa.pId === pid) {
            let item = TreeFuction(list, aaa.id);
    
            if (item.length > 0) {
                aaa.children = item;
            }
            tree.push(aaa);
        }
    }
    return tree;
}

var treeNode = TreeFuction(list, 0)

2.达成效果
在这里插入图片描述
3.通俗讲,就是造一个官方支持的数据格式

在这里插入图片描述

官方文档地址

https://1x.antdv.com/components/tree-select-cn

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在ant-design-vue中,showQuickJumper属性用于控制是否可以快速跳转至某一页。根据引用中的说明,showQuickJumper的类型是boolean,如果设置为true,那么快速跳转的输入框将会出现。如果你的showQuickJumper属性设置为true后仍然不生效,可能有以下几个原因: 1. 你未正确引入ant-design-vue库。请确保你已正确引入ant-design-vue库,并且版本与你当前使用的组件库版本一致。 2. 你可能未正确设置showQuickJumper属性。请检查showQuickJumper属性是否正确设置为true,并且没有被其他地方的设置覆盖。 3. 你可能在自定义样式中覆盖了showQuickJumper的样式。请检查自定义的样式文件中是否有修改showQuickJumper的相关样式。 如果你仍然无法解决showQuickJumper不生效问题,建议你查阅ant-design-vue的官方文档或者在相关社区寻求帮助,以获取更详细的解答。&lt;span class=&quot;em&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;em&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;em&quot;&gt;3&lt;/span&gt; #### 引用[.reference_title] - *1* [ant-design-vue和element-ui](https://blog.csdn.net/m0_51447279/article/details/109620737)[target=&quot;_blank&quot; data-report-click={&quot;spm&quot;:&quot;1018.2226.3001.9630&quot;,&quot;extra&quot;:{&quot;utm_source&quot;:&quot;vip_chatgpt_common_search_pc_result&quot;,&quot;utm_medium&quot;:&quot;distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1&quot;}}] [.reference_item style=&quot;max-width: 50%&quot;] - *2* *3* [基于ant-design-vue table 组件的使用](https://blog.csdn.net/qq_36437172/article/details/92653441)[target=&quot;_blank&quot; data-report-click={&quot;spm&quot;:&quot;1018.2226.3001.9630&quot;,&quot;extra&quot;:{&quot;utm_source&quot;:&quot;vip_chatgpt_common_search_pc_result&quot;,&quot;utm_medium&quot;:&quot;distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1&quot;}}] [.reference_item style=&quot;max-width: 50%&quot;] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值