异步查询回调函数调用

异步查询数据,需要对返回的数据进行后续步骤操作,使用使用方法:

1、new promise方法使用。

2、回调函数使用

  使用方式:  

 pageGetDeviceTreeInfo({deviceTypeAry:[1]},this.getTreeData); 

  函数:

1 export function pageGetDeviceTreeInfo(param,callback){  // 区域树接口查询,const param = {deviceType:1};//deviceType:1,人脸抓拍;2,车辆抓拍;3,WIFI感知;4,门禁感知
2   getRegionTree(param).then(rsp =>{
3     if(rsp.status==200){
4       callback(rsp.data);
5     } else {
6       callback([]);
7     }
8   });
9 };

  回调函数:

getTreeData(rstData){ // 回调函数
 console.log(rstData);
}

 

posted on 2019-05-27 16:13  紫藤萝yu  阅读(411)  评论(0编辑  收藏  举报