[英]migration from angular 5 to angular 7
昨天我已將我的應用程序從Angular 5遷移到角度7.在此過程中,我已按照建議在運行應用程序時將EventSource更改為EventSourcePolyfill。 但從那時起,我面臨一個奇怪的問題。 這就是我在控制台中遇到的問題如下:
ERROR TypeError: Cannot read property 'heartbeatTimeout' of undefined
at new EventSourcePolyfill (eventsource.js:155)
at AppFooterComponent.push../src/app/layout/footer/footer.component.ts.AppFooterComponent.connect (footer.component.ts:133)
at SafeSubscriber._next (footer.component.ts:52)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:196)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:134)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at AsyncAction.dispatch (timer.js:31)
at AsyncAction.push../node_modules/rxjs/_esm5/internal/scheduler/AsyncAction.js.AsyncAction._execute (AsyncAction.js:63)
at AsyncAction.push../node_modules/rxjs/_esm5/internal/scheduler/AsyncAction.js.AsyncAction.execute (AsyncAction.js:51)
這就是我在我的代碼中所做的:
import { EventSourcePolyfill } from 'ng-event-source';
let source = new EventSourcePolyfill('/api/v1/events/register');
任何人都可以建議我如何擺脫這個問題。
謝謝。
您必須傳遞其他參數,如
eventSource = new EventSourcePolyfill(url,
{ heartbeatTimeout: 5000, connectionTimeout: 5000, headers: { 'Authorization': 'Basic foo' }});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.