|
|
@ -16,7 +16,7 @@ Autocomplete select with search field. |
|
|
|
|
|
|
|
````jsx |
|
|
|
import { Input, Select, Button, Icon } from 'antd'; |
|
|
|
import jsonp from 'jsonp'; |
|
|
|
import jsonp from 'fetch-jsonp'; |
|
|
|
import querystring from 'querystring'; |
|
|
|
import classNames from 'classnames'; |
|
|
|
const Option = Select.Option; |
|
|
@ -36,19 +36,21 @@ function fetch(value, callback) { |
|
|
|
code: 'utf-8', |
|
|
|
q: value, |
|
|
|
}); |
|
|
|
jsonp(`https://suggest.taobao.com/sug?${str}`, (err, d) => { |
|
|
|
if (currentValue === value) { |
|
|
|
const result = d.result; |
|
|
|
const data = []; |
|
|
|
result.forEach((r) => { |
|
|
|
data.push({ |
|
|
|
value: r[0], |
|
|
|
text: r[0], |
|
|
|
jsonp(`https://suggest.taobao.com/sug?${str}`) |
|
|
|
.then(response => response.json()) |
|
|
|
.then((d) => { |
|
|
|
if (currentValue === value) { |
|
|
|
const result = d.result; |
|
|
|
const data = []; |
|
|
|
result.forEach((r) => { |
|
|
|
data.push({ |
|
|
|
value: r[0], |
|
|
|
text: r[0], |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
callback(data); |
|
|
|
} |
|
|
|
}); |
|
|
|
callback(data); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
timeout = setTimeout(fake, 300); |
|
|
|