constructor() {
this.searchInput.valueChanges
//.debounceTime(500) 无法使用
.pipe(debounceTime(1000))
.subscribe( stockCode => this.getStockInfo(stockCode)) ;
.....省略
}
运行这段代码时提示:ERROR in src/app/bind/bind.component.ts(25,8): error TS2339: Property ‘debounceTime’ does not exist on type ‘Observable’.
就是在Angular6中的rxjs 无法识别debounceTime()方法,将debounceTime(1000)修改为pipe(debounceTIme(1000))即可,同时import {debounceTime} from ‘rxjs/operators’; 问题即可解决。
参考:
https://www.cnblogs.com/coco1989/p/9371629.html
https://stackoverflow.com/questions/49811177/angular-6-rxjs-import-syntax#answer-50342338
https://github.com/ReactiveX/rxjs/issues/3723#issuecomment-390855559