TypeError:undefined不是对象(评估'parentOutlet.peekState')

问题描述 投票:0回答:2

我有一个多页的angular-nativescript应用程序(带有一个sidedrawer和一个page-router-outlet)。当我第一次启动应用程序时,我可以在侧面提取器上的页面之间导航就好了,但几分钟后(如10),尝试从一个页面导航到另一个页面时,使用以下消息使应用程序崩溃:

JavaScript错误: 文件:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:826:78: JS ERROR错误:未捕获(在承诺中):TypeError:undefined不是对象(评估'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 <\ M-B \ M -1 @ \ M-&> * JavaScript调用堆栈: ( 0 UIApplicationMain @ [本机代码] 1启动@ file:///app/tns_modules/tns-core-modules/application/application.js:272:26 2运行@ 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 moduleEvaluation @:1:11 9 promiseReactionJob @:1:11 ) *由于未捕获的异常而终止应用程序'NativeScript遇到致命错误:错误:未捕获(在承诺中):TypeError:undefined不是对象(评估'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分钟

angular angular2-routing angular2-nativescript
2个回答
0
投票

似乎问题与我如何处理角度版本之间的路由有关。在角度4我使用<router-outlet>并且在围绕它的tkMainContent<StackLayout>。当我在角度6中切换到使用<page-router-outlet>时,我需要将tkMainContent移动到<page-router-outlet>内部


0
投票

我有同样的错误,我发现它是因为我在main.ts文件中使用它:

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

将此更改为:

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

要么

platformNativeScriptDynamic().bootstrapModule(AppModule);

解决了这个问题。

尝试加载使用根视图显示模态的模态时,会出现此错误。

根据NativeScript文档,你应该在你的应用程序不使用createFrameOnBootstrap的情况下使用page-router-outlet,因为没有它你就不会得到默认的PageFrame,这意味着你将无法将它们注入你的组件或显示ActionBar

我的应用程序有qazxsw poi,所以设置qazxsw poi解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.