我在做一个Angular 6项目.
运行ng lint会发出以下警告:
"已弃用forkJoin:已弃用ResultSelector,请改为通过管道连接到映射"
forkJoin(...observables).subscribe(
有什么 idea 吗?似乎找不到有关此弃用的任何信息.
我刚刚用Angular CLI:6.1.5生成了一个全新的Angular应用程序"ng new forkApp"
来源:
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { forkJoin } from 'rxjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'forkApp';
constructor(private http: HttpClient) {}
ngOnInit() {
console.log('ngOnInit...');
const obs = [];
for (let i = 1; i < 4; i++) {
const ob = this.http.get('https://swapi.co/api/people/' + i);
obs.push(ob);
}
forkJoin(...obs)
.subscribe(
datas => {
console.log('received data', datas);
}
);
}
}
包中的"依赖项"部分.json文件:
"dependencies": {
"@angular/animations": "^6.1.0",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "~0.8.26"
},
一旦所有三个GET请求都完成,我就获得了"数据"数组中的所有数据.
C:\forkApp>;ng lint
警告:C:/forkApp/src/app/app.组成部分ts[26,5]:forkJoin是