Element: The [Feature Request] input does not support the specified data source for the proposed Input input box

Created on 22 Jun 2017  ·  9Comments  ·  Source: ElemeFE/element

Existing Component

Component Name

input

Description

http://element.eleme.io/#/zh-CN/component/input
带建议的输入框不支持指定数据源.
文档中的 querySearch 方法必须指定 方法为 (queryStr,callback)=>{ ... }
建议如果可以支持成
(queryStr,source ,callback)=>{
//filter from source
//从传参指定的数据源中筛选数据就好了
}
如果不可以,那么也就只能在focus的时候自行实现代码指定filter的数据源了, 这样很不方便.

另外, 使用 v-for 动态添加的input ,动态出来就自动触发了 :fetch-suggestions ,:focus,有点不妥.这也许是一个bug.

Most helpful comment

可以在你的 search 外面包一层:https://jsfiddle.net/8su1jswq/

All 9 comments

Translation of this issue:

Existing Component

yes

Component Name

Input

Description

Http://element.eleme.io/#/zh-CN/component/input

The specified input box does not support the specified data source
The querySearch method in the document must specify the method (queryStr, callback) =>{}...

Suggest if you can support
(queryStr, source, callback) =>{

//filter from source
From / / parameters specified data source selection data is good

}
If not, then you can only implement the code to specify the data source of the filter at focus, which is very inconvenient

In addition, using V-for dynamically added input, dynamic out automatically triggered: fetch-suggestions: focus, a bit inappropriate. This may be a bug.

没有太理解你的需求,数据源具体是什么?fetch-suggestions 是需要自己去实现的,用任何数据都可以。

@Leopoldthecoder

问题如下代码:

<div v-for="item in 100">
    <el-input :focus='console.log(item)'></el-input>
<div>

屏幕上输出了的输出框, 我在选中其中一个的时候, 会在console中打印100次 . 应该是1次, 所以这儿有个bug.

focus 是事件,要用 @ 而不是 :<el-input @focus="handleFocus(item)"></el-input>。另外,这个和上面说的 AutoComplete 的问题有关系?

使用@focus是一个替代如下的方案.
有个场景是, 用户在使用 带suggest的输入框的时候, 其suggest信息需要根据上下文关系进行自动处理suggest 的数据源.

<div v-for="item in 100">
    <el-input @focus='console.log(item)' :fetch-suggestions='search'></el-input>
<div>

我的方案是, 使用@focus来判断我当前在哪个 input中.假设保存在全局变量focusitem 中,
然后在input中进行输入的时候, 在fetch-suggestions的实现中去读取这个focusitem, 用以确定我suggest的数据源应该用什么.打个比方逻辑是, 在item在0到50的时候,使用 A 数据源, 在51到100 的时候使用B 数据源.

如果fetch-suggest能够满足如下, 就更加方便.

<div v-for="item in 100">
    <el-input  :fetch-suggestions='search(item,querystring , callback)'></el-input>
<div>

也就是说参数中可选的能够添加一些特殊的数据.

(queryString , callback , data ?) =>{ }

可以在你的 search 外面包一层:https://jsfiddle.net/8su1jswq/

谢谢, 我想请你喝杯咖啡, 再加个鸡腿. #

谢谢, 我也想请你喝杯咖啡, 再加个鸡腿. #

(queryString, cb) => {querySearch(queryString, i, cb)}
上面的语法专业叫法叫啥?

Was this page helpful?
0 / 5 - 0 ratings