在componentWillMount中请求数据后,将拿到的数据setState操作后,在setState回调中能否再用state中的参数发起ajax请求后再将拿回的数据setStatecomponentWillMount(){let appId = this.GetQueryString('appId')let language = this.GetQueryString('language')axios.post('/api/language/findAll').then(res=>{ console.log('0000') for(let i=0;i<res.length;i++){ if(res[i].en==language){ this.setState({ language:res[i].pid, appId:appId },()=>{ this.queryConfig() }) } }})}queryConfig(){let params={ appId:this.state.appId, lang:this.state.language}axios.post('/api/spirit/config',params).then(res=>{ console.log('第二个请求') this.setState({ custom:res.spirit.custom, recommend:res.spirit.recommend, strategy:res.spirit.strategy, },()=>{console.log('第二次渲染')})})};
添加回答
举报
0/150
提交
取消