我正在尝试使用async/ await(第一次),但我无法理解它。
我在这里做错了什么:
tree.component.ts
export class TreeComponent implements OnInit {
private routeSub: any;
acronym: string;
flare: any[];
constructor(
private location: Location,
private route: ActivatedRoute,
private http: HttpClient,
private router: Router,
private fileTreeService: FileTreeService
) {
}
ngOnInit(): void {
this.routeSub = this.route.params.subscribe(
params => {
this.acronym = params.name
this.fileTreeService.getFileTree(params.name).subscribe(item => {
this.flare = item;
});
});
Run Code Online (Sandbox Code Playgroud)
文件树.service.ts
export class FileTreeService {
res: any;
constructor(private http: HttpClient) { }
async getFileTree(acronym) {
const headers = new HttpHeaders()
this.res …Run Code Online (Sandbox Code Playgroud)