1,(伪)同步请求获取后台数据,按先后顺序执行请求,示例:
import { map, mergeMap } from "rxjs/operators";
this.http.get("api/sysCityRegion/address", { parentId: "CN" }).pipe(mergeMap((res: any) => {
this.province = res;
this.region = [];
this.city = [];
this.provinceCode = "150000";
this.regionCode = null;
this.cityCode = null;
return this.http.get("api/sysCityRegion/address", { parentId: "150000" }) //默认设置市
})).pipe(mergeMap((res1: any) => {
this.city = res1;
this.region = [];
this.regionCode = null;
this.cityCode = "150500";
return this.http.get("api/sysCityRegion/address", { parentId: "150500" })//默认设置区
})).subscribe((res2: any) => {
this.region = res2;
this.regionCode = null;
})
2,当满足一定条件时,才加载simple-table的数据,解决方法:
<simple-table #st_card [data]="url_card" [extraParams]="model_card" [scroll]="{x: '1250px'}"
[columns]="columns_card" toTopInChange showSizeChanger showQuickJumper showTotal>
<ng-template st-row="seqCmp" let-item let-index="index">
{{item.disable?'-':index+1+(st_card.pi-1)*st_card.ps}}
</ng-template>
</simple-table>
===》 最开始不初始化url_card,待异步请求后台返回满足条件后,再对url_card进行赋值即可