-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
What problem does this feature solve?
缓存更多数据,避免重新构造。
What does the proposed API look like?
在AutoComplete中,当我们输入一个词后,自动完成下拉列表中会展现候选词数组,标准格式是DataSourceItemType
[{text:'候选词1', value:'值1'}, {text:'候选词2', value:'值2'}] 或者简单格式['候选词1', '候选词2']
但是我们在使用的时候,需要的数据可能不仅仅是text或者value,还有些是当前value关联的一些属性。能不能在生成dataSource的时候,可以接受并渲染额外的字段?,比如otherInfo:
dataSource = [{text:'候选词1', value:'值1', otherInfo:{att1:'', att2:'', att3:''}}, {text:'候选词2', value:'值2'}]
渲染的时候把otherInfo对象渲染到下拉中。 当响应select 事件的时候,
onSelect (value, option) {
// 通过这个获取额外的属性
console.log(option.data.attr.otherInfo)
}
这样就避免了,我们在选中的时候,还需要另外通过一个接口,根据当前选择的value,去获取跟它关联的otherInfo。