異步查詢數據,需要對返回的數據進行后續步驟操作,使用使用方法:
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);
}
?