Browse Source

docs: update demo for SSR

pull/4244/merge
Benjy Cui 8 years ago
parent
commit
9f2e6c8baa
  1. 28
      components/select/demo/search-box.md
  2. 2
      package.json

28
components/select/demo/search-box.md

@ -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);

2
package.json

@ -112,7 +112,7 @@
"jest-cli": "^17.0.0",
"jsonml-to-react-component": "~0.2.0",
"jsonml.js": "^0.1.0",
"jsonp": "^0.2.0",
"fetch-jsonp": "^1.0.3",
"lesshint": "^2.0.0",
"lodash.debounce": "^4.0.6",
"mockdate": "^2.0.1",

Loading…
Cancel
Save