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

TreeSelect组件,怎么自定义数组显示? #2253

Closed
1 task
noecs opened this issue May 17, 2020 · 7 comments
Closed
1 task

TreeSelect组件,怎么自定义数组显示? #2253

noecs opened this issue May 17, 2020 · 7 comments
Labels

Comments

@noecs
Copy link

noecs commented May 17, 2020

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

Version

1.6.0

Environment

macOS Sierra, Chrome, vue-antd-pro:2.1.0

Reproduction link

Edit on CodeSandbox

Steps to reproduce

TreeSelect

使用自定义的数组该怎么正常显示?
数据格式例如:

[
        {
          id: 2,
          name: "测试",
          children: [
            {
              id: 3,
              name: "测试内",
              children: []
            }
          ]
        },
        {
          id: 4,
          name: "测试2",
          children: [
            {
              id: 5,
              name: "测试内3",
              children: []
            }
          ]
        }
]

What is expected?

我期望它能够在下拉框中显示name值,并且在选择的时候修改this.data为选择的name对应ID值,

What is actually happening?

实际中,树状下拉框不显示name,只显示了---

@edenleung
Copy link

你还没配置 titlevalue

<template>
  <div style="margin: 24px">
    <a-tree-select
      v-model="value"
      style="width: 100%"
      :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
      :tree-data="tree"
      placeholder="Please select"
      tree-default-expand-all
    >
      <span slot="name" slot-scope="{ name, id }" style="color: #08c">{{ name }}</span>
    </a-tree-select>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      value: 2,
      tree: [
        {
          id: 2,
          title: "测试",
          value: 2,
          children: [
            {
              id: 3,
              title: "测试内",
              value: 3,
              children: []
            }
          ]
        },
        {
          id: 4,
          title: "测试2",
          value: 4,
          children: [
            {
              id: 5,
              title: "测试内3",
              value: 5,
              children: []
            }
          ]
        }
      ]
    };
  }
};
</script>

<style></style>
`

@noecs
Copy link
Author

noecs commented May 17, 2020

@edenleung 这个title,value不支持自定义吗?

@tangjinzhou
Copy link
Member

下个版本支持

@buildJava
Copy link

treeNodeFilterProp, treeNodeLabelProp是这两个字段吗,升级到1.6.1版本的api,
image
image
不生效呢

@buildJava
Copy link

通过配置replaceFields: { title: 'deptName', key: 'id', value: 'id' }生效了,那么想问下reeNodeFilterProp, treeNodeLabelProp这两个字段的作用是什么

@Quantriple
Copy link

通过配置replaceFields: { title: 'deptName', key: 'id', value: 'id' }生效了,那么想问下reeNodeFilterProp, treeNodeLabelProp这两个字段的作用是什么

哥们,replaceFields: 这个生效了吗,我这边没有生效。。。版本升级到了1.6.1

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants