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

ProTable时DataSource的数据格式不支持string[] #7343

Closed
annilq opened this issue Jul 10, 2023 · 5 comments
Closed

ProTable时DataSource的数据格式不支持string[] #7343

annilq opened this issue Jul 10, 2023 · 5 comments
Labels

Comments

@annilq
Copy link

annilq commented Jul 10, 2023

🐛 bug 描述

当使用ProTable时DataSource的数据格式为string[]等基础数据类型时会报错,此bug是因为使用了Reflect.has方法导致,此方法不支持基本类型

💻 复现代码

代码示例

@github-actions
Copy link

以下的 Issues 可能会帮助到你 / The following issues may help you

@chenshuai2144
Copy link
Contributor

TAutomatically replying with ChatGPT can be attempted, but it cannot be guaranteed to be completely accurate and may not fully address all issues. Please feel free to reply if you have any further questions or concerns.
此回复基于 ChatGPT 自动生成,可以尝试下方案,官方人员会在一定时间后继续继续处理。

很抱歉,由于我是一个文字助手,无法访问链接或执行代码。但是我可以尝试为您提供一些初步的解决方案和文档。请尝试以下步骤来解决ProTable中DataSource数据格式不支持string[]的问题:

  1. 确保您的React项目中安装了最新版本的ProTable组件。

  2. 将DataSource的数据格式更改为对象数组。每个对象应包含一个key和一个value字段,其中key是列名,value是对应的值。例如:

const dataSource = [
  { key: '1', value: 'Value 1' },
  { key: '2', value: 'Value 2' },
  { key: '3', value: 'Value 3' },
];
  1. 在ProTable组件中,使用columns属性配置列的名称和数据类型。确保每列的dataIndex属性与DataSource数组中的key字段匹配。例如:
const columns = [
  {
    title: 'Column 1',
    dataIndex: '1',
    key: '1',
  },
  {
    title: 'Column 2',
    dataIndex: '2',
    key: '2',
  },
  {
    title: 'Column 3',
    dataIndex: '3',
    key: '3',
  },
];

<ProTable dataSource={dataSource} columns={columns} />

这样,您就可以在ProTable中正确显示基于string[]的数据了。

此外,您还可以查看ProTable文档以获取更多关于DataSource和列配置的信息:

请注意,这只是一个初步的解决方案,实际解决问题可能会根据您的具体代码和环境而有所不同。

@annilq
Copy link
Author

annilq commented Jul 14, 2023

TAutomatically replying with ChatGPT can be attempted, but it cannot be guaranteed to be completely accurate and may not fully address all issues. Please feel free to reply if you have any further questions or concerns.
此回复基于 ChatGPT 自动生成,可以尝试下方案,官方人员会在一定时间后继续继续处理。

很抱歉,由于我是一个文字助手,无法访问链接或执行代码。但是我可以尝试为您提供一些初步的解决方案和文档。请尝试以下步骤来解决ProTable中DataSource数据格式不支持string[]的问题:

  1. 确保您的React项目中安装了最新版本的ProTable组件。
  2. 将DataSource的数据格式更改为对象数组。每个对象应包含一个key和一个value字段,其中key是列名,value是对应的值。例如:
const dataSource = [
  { key: '1', value: 'Value 1' },
  { key: '2', value: 'Value 2' },
  { key: '3', value: 'Value 3' },
];
  1. 在ProTable组件中,使用columns属性配置列的名称和数据类型。确保每列的dataIndex属性与DataSource数组中的key字段匹配。例如:
const columns = [
  {
    title: 'Column 1',
    dataIndex: '1',
    key: '1',
  },
  {
    title: 'Column 2',
    dataIndex: '2',
    key: '2',
  },
  {
    title: 'Column 3',
    dataIndex: '3',
    key: '3',
  },
];

<ProTable dataSource={dataSource} columns={columns} />

这样,您就可以在ProTable中正确显示基于string[]的数据了。

此外,您还可以查看ProTable文档以获取更多关于DataSource和列配置的信息:

请注意,这只是一个初步的解决方案,实际解决问题可能会根据您的具体代码和环境而有所不同。

这个方案的确可行,但是这个问题是由于我们升级依赖产生的,目前我们不确定有哪些基础模块有这个问题,所以这种方法不太适合升级,目前已经把依赖切换回低版本确保项目运行,等到官方修复bug再进行升级

@chenshuai2144
Copy link
Contributor

虽然不是不能用,但是推荐还是不要这么用。这样用起来很容易出问题

@annilq
Copy link
Author

annilq commented Jul 15, 2023

主要是低版本没问题,如果最开始有问题我们酒不会这么用了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants