?//請求數(shù)據(jù)的方法,需要return【注意加粗的地方】
genData(pageNo,area_id,value){
? ? ? return axios.ajax({
? ? ? ? ? ? url:'/api/v1/vas/shop',
? ? ? ? ? ? method:'get',
? ? ? ? ? ? data:{
? ? ? ? ? ? ? ? area_id:area_id,
? ? ? ? ? ? ? ? name:value,
? ? ? ? ? ? ? ? page:pageNo,
? ? ? ? ? ? ? ? size:10
? ? ? ? ? ? }
? ? ? ? }).then((res)=>{
? ? ? ? ? if(res.code===0){
? ? ? ? ? ? console.log(res.data);
? ? ? ? ? ? this.setState({
? ? ? ? ? ? ? isLoading: false,
? ? ? ? ? ? ? refreshing: false,
? ? ? ? ? ? });
? ? ? ? ? ? if(res.data){
? ? ? ? ? ? ? if(res.data.length<=0){
? ? ? ? ? ? ? ? this.setState({
? ? ? ? ? ? ? ? ? hasMore: false
? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? this.setState({
? ? ? ? ? ? ? ? ? ? hasMore: true
? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? }
? ? ? ? ? ? ? return res.data;
? ? ? ? ? ? }else{
? ? ? ? ? ? }
? ? ? ? ? }
? ? ? ? });
? ? ? }
//獲取服務(wù)器返回的數(shù)據(jù)费彼,需要調(diào)用方法genData()要出,并.then()獲取里面value即接收到的數(shù)據(jù)
this.genData(1).then((value)=>{
? ? ? ? ? console.log(value);
? ? ? ? ? this.rData=[...value];
? ? ? ? ? console.log('rData:',this.rData);
? ? ? ? ? this.setState({
? ? ? ? ? ? dataSource: this.state.dataSource.cloneWithRows(this.rData),
? ? ? ? ? });
? ? ? ? });