angular - 为什么不推荐使用 subscribe/observable 上的数据和错误?
angular - Why using the data and error on the subscribe/observable like this is deprecated?
为什么这个被弃用了?正确的形式是怎样的?
getPeopleFunction() {
this.peopleService.getPeopleService().subscribe(
(data) => {
console.log(data);
},
(error) => {
console.log(error);
}
);
}
您现在应该使用这种格式:
this.peopleService.getPeopleService().subscribe({
next: (v) => console.log(v),
error: (e) => console.error(e),
complete: () => console.info('complete')
})
为什么这个被弃用了?正确的形式是怎样的?
getPeopleFunction() {
this.peopleService.getPeopleService().subscribe(
(data) => {
console.log(data);
},
(error) => {
console.log(error);
}
);
}
您现在应该使用这种格式:
this.peopleService.getPeopleService().subscribe({
next: (v) => console.log(v),
error: (e) => console.error(e),
complete: () => console.info('complete')
})