我在React中使用React-Select Plus控件进行绑定下拉。我在React中绑定异步选项组下拉时发现了问题。 我的代码在这里:
getSearch = (input) => {
if (!input) {
return Promise.resolve({ options: [] });
}
const newstate = this.state;
this.setState({ newstate });
newstate.loadingtext = 'Searching...';
const searchLocation = Object.assign({}, cookie.load('cLocation'));
searchLocation.searchText = input;
searchLocation.isBusiness = true;
const myInit = {
method: 'POST',
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify(searchLocation),
};
return fetch(`url/methodname`, myInit)
.then(response => response.json())
.then(json => [{ value: json.data, label: json.data }]);
}
gotoSearch = (value) => {
window.open(value.html_url);
}

<Select.Async
onChange={this.onChange}
onValueClick={this.gotoSearch}
valueKey="placeID"
labelKey="cityState"
loadOptions={this.getSearch}
value={this.state.value}
loadingPlaceholder={this.state.loadingtext}
noResultsText="No results found"
placeholder="Name, City, Zip"
options={ops}
/>
&#13;
我引用此网址:http://github.hubspot.com/react-select-plus/
请帮帮我。