Tux*_*Joe 2 rxjs5 angular angular5 angular6 rxjs6
尝试从 5 升级到 Angular 6 并收到此错误:
src/app/app.component.ts(26,23) 中的错误:错误 TS2339:“Observable”类型上不存在“distinctUntilChanged”属性。
我在 app.module.ts 中导入了 distinctUntilChanged:
import "rxjs/add/operator/distinctUntilChanged";
Run Code Online (Sandbox Code Playgroud)
我在 app.component.ts 中的代码:
import { Component } from "@angular/core"; import { Router, NavigationEnd } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { GeoService } from "app/services/geo.service";
import { ArbeteService } from "app/services/arbete.service";
import { GoogleAnalyticsEventsService } from "app/services/google-analytics-events.service";
import * as _ from "lodash";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"]
})
export class AppComponent {
//Send pageview to Google Analytics
router.events.distinctUntilChanged((previous: any, current: any) => {
if (current instanceof NavigationEnd) {
return previous.url === current.url;
}
return true;
}).subscribe((x: any) => {
googleAnalytics.emitVirtualPageView("Rekryteringsguiden", "Rekryteringsguiden");
});
Run Code Online (Sandbox Code Playgroud)
我在这里缺少什么?
import { distinctUntilChanged } from 'rxjs/operators';
router.events.pipe(distinctUntilChanged((previous: any, current: any) => {})).subscribe();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4918 次 |
| 最近记录: |