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

AutoComplete The console will report an error when using the option that directly passes #dataSource to the AutoComplete component. It is not recommended to use the datasource. How can I customize the options with options? #4012

Closed
1 task
cff-github opened this issue Apr 28, 2021 · 7 comments
Assignees

Comments

@cff-github
Copy link

cff-github commented Apr 28, 2021

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

Version

2.1.3

Environment

2.1.2

Reproduction link

#3210

Steps to reproduce

AutoComplete 自动完成组件在使用 #dataSource 自定义Option时控制台会报错(不推荐使用datasource,建议用options),请问如何用options自定义选项

What is expected?

希望能自定义选项并且控制台不报错

What is actually happening?

AutoComplete 自动完成级件在使用直接传递 #dataSource 的Option时控制台会报错不推荐使用datasource,请问如何用options自定义选项

@github-actions github-actions bot changed the title AutoComplete 自动完成级件在使用直接传递 #dataSource 的Option时控制台会报错不推荐使用datasource,请问如何用options自定义选项 AutoComplete The console will report an error when using the option that directly passes #dataSource to the AutoComplete component. It is not recommended to use the datasource. How can I customize the options with options? Apr 28, 2021
@zkwolf
Copy link
Member

zkwolf commented Apr 28, 2021

就是prop改名了吧

@zzxxiinn
Copy link

const AutoCompleteProps = {
...SelectProps(),
dataSource: PropTypes.array,
dropdownMenuStyle: PropTypes.style,
optionLabelProp: PropTypes.string,
dropdownMatchSelectWidth: PropTypes.looseBool,
};

由于上面的定义,下面这里的代码判断 'dataSource' in slots 会为 true

!(props.dataSource !== undefined || 'dataSource' in slots),

所以这里是需要改进的。

@zkwolf
Copy link
Member

zkwolf commented Jun 22, 2021

@John60676

@John60676
Copy link
Member

@zzxxiinn 你是不是看错了,定义的是 props,判断的是 'dataSource' in slots,怎么会是 true

@zzxxiinn
Copy link

zzxxiinn commented Jul 1, 2021

@John60676 感谢回复指出,上面是我引用的不对。不过我在 error stack 中看到报错是

// webpack:///./node_modules/ant-design-vue/es/auto-complete/index.js?28da
 setup: function setup(props, _ref) {
    var slots = _ref.slots;
    warning(!('dataSource' in props || 'dataSource' in slots), 'AutoComplete', '`dataSource` is deprecated, please use `options` instead.');
    return {
      configProvider: inject('configProvider', defaultConfigProvider),
      popupRef: null,
      select: null
    };
  },

用的 antd 版本是 version "2.1.6"

@John60676
Copy link
Member

@zzxxiinn 这个 issue 在 2.2.0-beta.5 解决的,你可以更新一下版本

@github-actions
Copy link

github-actions bot commented Jul 2, 2022

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 Jul 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants