簡體   English   中英

TypeError:未定義不是對象(評估“ parentOutlet.peekState”)

[英]TypeError: undefined is not an object (evaluating 'parentOutlet.peekState')

我有一個多頁的angular-Nativescript應用程序(帶有一個抽屜和一個頁面路由器出口)。 首次啟動應用程序時,我可以在側邊抽屜上的頁面之間導航,但是幾分鍾(例如10分鍾)后,嘗試從一個頁面導航到另一頁面會導致此消息崩潰:

JavaScript錯誤:
文件:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:826:78:
JS錯誤錯誤:未捕獲(承諾):TypeError:未定義不是對象(正在評估“ parentOutlet.peekState”)
upsertModalOutlet @文件:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:506:41
文件:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:128:44
forEach @ [本地代碼]
pushStateInternal @文件:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:111:54
pushState的@文件:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:85:31
pushState的@文件:///app/tns_modules/nativescript-angular/router/ns-platform-location.js:49:40
pushState的@文件:///app/tns_modules/@angular/common/bundles/common.umd.js:511:45
去@文件:///app/tns_modules/@angular/common/bundles/common.umd.js:286:45
setBrowserUrl @文件:///app/tns_modules/@angular/router/bundles/router.umd.js:4007:33
文件:///app/tns_modules/@angular/router/bundles/router.umd.js:3960:40
文件:///應用程序/ tns_m <\\ MB \\ M -1 @ \\ M-&>
* JavaScript調用堆棧:

0 UIApplicationMain @ [本地代碼]
1個start @ file:///app/tns_modules/tns-core-modules/application/application.js:272:26
2 run @ file:///app/tns_modules/tns-core-modules/application/application.js:300:10
3 bootstrapNativeScriptApp @ file:///app/tns_modules/nativescript-angular/platform-common.js:185:26
4 bootstrapApp @ file:///app/tns_modules/nativescript-angular/platform-common.js:103:38
5 bootstrapModule @ file:///app/tns_modules/nativescript-angular/platform-common.js:87:26
6匿名@file:///app/main.js:7:57
7評價@ [本地代碼]
8個模塊評估@:1:11
9 promiseReactionJob @:1:11

*由於未捕獲的異常'NativeScript遇到致命錯誤而終止應用程序:錯誤:未捕獲(承諾中):TypeError:未定義不是對象(正在評估'parentOutlet.peekState')
upsertModalOutlet @文件:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:506:41
文件:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:128:44
forEach @ [本地代碼]
pushStateInternal @文件:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:111:54
pushState的@文件:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:85:31
pushState的@文件:///app/tns_modules/nativescript-angular/router/ns-platform-location.js:49:40
pushState的@文件:///app/tns_modules/@angular/common/bundles/common.umd.js:511:45
go @ file:///app/tns_modules/@angular/common/bundles/common.umd.js:286:45 setBrowserUrl @ file:///app/tns_modules/@angular/router/bundles/router.umd.js :4007:33
文件:///app/tns_modules/@angular/router/bundles/router.umd.js:3960:40

它可以可靠地重現,但每次都需要等待大約10分鍾

好像問題出在我處理角度版本之間的路由有關。 在角度4我所用的<router-outlet>並具有tkMainContent<StackLayout>這是圍繞着它。 當我在角度6中切換為使用<page-router-outlet> ,我需要將tkMainContent移動到<page-router-outlet>

我有同樣的錯誤,我發現這是因為我在main.ts文件中使用了此main.ts

platformNativeScriptDynamic({createFrameOnBootstrap: true}).bootstrapModule(AppModule);

更改為:

platformNativeScriptDynamic({createFrameOnBootstrap: false}).bootstrapModule(AppModule);

要么

platformNativeScriptDynamic().bootstrapModule(AppModule);

解決了問題。

嘗試加載使用根視圖顯示模態的模態時,尤其會出現此錯誤。

根據NativeScript文檔,在應用程序不使用page-router-outlet情況下,應使用createFrameOnBootstrap ,因為沒有它,您將無法獲得默認的Page and Frame ,這意味着您將無法將它們注入到組件中或顯示ActionBar

我的應用程序具有page-router-outlet ,因此設置createFrameOnBootstrap: false解決了此問題。

暫無
暫無

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

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