簡體   English   中英

read.ts(6133)模塊'“ ../../../node_modules/rxjs/observable/combineLatest”'沒有導出的成員'combineLatest'.ts(2305)

[英]read.ts(6133) Module '“../../../node_modules/rxjs/observable/combineLatest”' has no exported member 'combineLatest'.ts(2305)

如何通過CombineLatest合並Observable。 未定義CombineLatest

我正在使用angular js7。我想添加兩個查詢字符串參數,但是當我編寫obserable.combinelaste([])時,它將給出en錯誤。

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable, of, observable } from 'rxjs'
import { combineLatest } from 'rxjs/observable/combineLatest';
@Component({
  selector: 'app-githubfollowers',
  templateUrl: './githubfollowers.component.html',
  styleUrls: ['./githubfollowers.component.css']
})
export class GithubfollowersComponent implements OnInit {

  constructor(private rout:ActivatedRoute ) { }

  ngOnInit() {
    Observable.combineLatest([  this.rout.paramMap,
  this.rout.queryParamMap

    ]);

    this.rout.paramMap.subscribe(prams=>{

    });
    this.rout.queryParamMap.subscribe(prams=>{

    });
  }

}

您輸入錯誤。 您將導入用於RXJS v5。

對於RxJS v6 +,您應該使用以下導入:

import { combineLatest } from 'rxjs';

解決以下錯誤信息:

ngOnInit(){Observable.combineLatest([this.rout.paramMap,this.rout.queryParamMap]); 類型“ typeof Observable”上不存在屬性“ combineLatest”

您可以像這樣使用combineLatest

combineLatest(this.rout.paramMap, this.rout.queryParamMap)

您可能需要花一些時間來閱讀如何使用它: https : //www.learnrxjs.io/operators/combination/combinelatest.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM