使用名称对数组进行排序我有一个数组.
array(0 => Mr. Bala ,1 => Mr. Santhosh, 2 => Mrs. Camel,3 => Mrs. Vinoth);
Run Code Online (Sandbox Code Playgroud)
仅根据名称按升序对其进行排序
我的预期产量是
array(
0 => Mr. Bala,
1 => Mrs. Camel,
2 => Mr. Santhosh,
3 => Mr. Vinoth,
);
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我需要将异步转换为同步(即)一旦 setState 设置了值,那么我需要在调用后从 api 获取数据
logChange(val) {
this.setState({
fetchIntentReport: {
startDate: this.state.fetchIntentReport.startDate,
endDate: this.state.fetchIntentReport.endDate,
intents: val.split(','),
},
});
this.props.fetchIntentReports({
startDate: this.state.fetchIntentReport.startDate,
endDate: this.state.fetchIntentReport.endDate,
intents: this.state.fetchIntentReport.intents,
});
}
Run Code Online (Sandbox Code Playgroud)
一旦值设置为意图,那么我需要通过 redux 调用 fetchIntentReports api 调用。