NativeScript-Angular:nsRouterLink在Android上打开组件,但在iOS上不打开

时间:2019-07-01 11:14:33

标签: nativescript nativescript-angular

使用nsRouterLink打开新窗口在Android上有效,但在iOS上无效。

点击该按钮:

<Button text="Tap me to open child component" [nsRouterLink]="['../child']" ></Button>

在Android上运行良好,但在iOS上崩溃。

这是一个游乐场模型:

NativeScript Playground sample

这是iOS崩溃日志:

[Test iPhone]: The Preview app has terminated unexpectedly. Please run it again to get a detailed crash report.
[Test iPhone]: 2019-07-02 11:59:59.665 nsplaydev[1064:606206] ***** Fatal JavaScript exception - application has been terminated. *****
2019-07-02 11:59:59.665 nsplaydev[1064:606206] Native stack trace:
1 0x1013473b0 NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
2 0x101378db4 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
3 0x101dddfa4 ffi_closure_SYSV_inner
4 0x101de01b4 .Ldo_closure
5 0x1bbdfb6e4 <redacted>
6 0x1bbdfbdb0 <redacted>
7 0x1bbd53578 <redacted>
8 0x1bbd674b8 <redacted>
9 0x1bbd688e0 <redacted>
10 0x1bbd4baf0 <redacted>
11 0x1bc836ed0 <redacted>
12 0x194091a20 <redacted>
13 0x1940969c8 <redacted>
14 0x193ff92d0 <redacted>
15 0x194027330 <redacted>
16 0x194027f20 <redacted>
17 0x18fb6e5f8 <redacted>
18 0x18fb69320 <redacted>
19 0x18fb6989c <redacted>
20 0x18fb690b0 CFRunLoopRunSpecific
21 0x191d6979c GSEventRunModal
22 0x1bc39f978 UIApplicationMain
23 0x101de0044 ffi_call_SYSV
24 0x101ddd6c4 ffi_call_int
25 0x101ddd1c0 ffi_call
26 0x10130cb80 NativeScript::FunctionWrapper::call(JSC::ExecState*)
27 0x101ddc268 llint_entry
28 0x101ddb6c4 llint_entry
29 0x101ddb6c4 llint_entry
30 0x101ddb6c4 llint_entry
31 0x101ddb6c4 llint_entry
2019-07-02 11:59:59.675 nsplaydev[1064:606206] JavaScript stack trace:
2019-07-02 11:59:59.675 nsplaydev[1064:606206] 1 @file:///app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:134:25
2 eachChildView@file:///app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:125:28
3 eachLayoutChild@file:///app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:133:23
4 onMeasure@file:///app/tns_modules/tns-core-modules/ui/layouts/grid-layout/grid-layout.js:107:25
5 measure@file:///app/tns_modules/tns-core-modules/ui/core/view/view.js:55:21
6 measureChild@file:///app/tns_modules/tns-core-modules/ui/core/view/view-common.js:929:20
7 onMeasure@file:///app/tns_modules/tns-core-modules/ui/action-bar/action-bar.js:302:44
8 measure@file:///app/tns_modules/tns-core-modules/ui/core/view/view.js:55:21
9 layoutInternal@file:///app/tns_modules/tns-core-modules/ui/action-bar/action-bar.js:132:17
10 update@file:///app/tns_modules/tns-core-modules/ui/action-bar/action-bar.js:202:26
11 onLoaded@file:///app/tns_modules/tns-core-modules/ui/page/page.js:240:28
12 @file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:311:93
13 callFunctionWithSuper@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:304:9
14 callLoaded@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:311:31
15 loadView@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:439:22
16 _addViewCore@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:434:20
17 _addView@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:420:22
18 viewWillAppear@file:///app/tns_modules/tns-core-modules/ui/page/page.js:81:23
19 UIApplicationMain@[native code]
20 _start@file:///app/tns_modules/tns-core-modules/application/application.js:277:22
21 run@file:///app/tns_modules/tns-core-modules/application/application.js:309:9
22 bootstrapNativeScriptApp@file:///app/tns_modules/nativescript-angular/platform-common.js:205:22
23 bootstrapApp@file:///app/tns_modules/nativescript-angular/platform-common.js:106:34
24 bootstrapModule@file:///app/tns_modules/nativescript-angular/platform-common.js:90:22
25 anonymous@file:///app/main.js:8:57
26 evaluate@[native code]
27 moduleEvaluation@[native code]
28 promiseReactionJob@[native code]
2019-07-02 11:59:59.676 nsplaydev[1064:606206] JavaScript error:
file:///app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:134:25: JS ERROR TypeError: undefined is not a function (near '...cv._eachLayoutView...')
2019-07-02 11:59:59.678 nsplaydev[1064:606206] PlayLiveSync: Uncaught Exception
2019-07-02 11:59:59.679 nsplaydev[1064:606206] PlayLiveSync: Sending crash report
2019-07-02 12:00:03.681 nsplaydev[1064:606206] *** JavaScript call stack:
(
0 UIApplicationMain@[native code]
1 _start@file:///app/tns_modules/tns-core-modules/application/application.js:277:22
2 run@file:///app/tns_modules/tns-core-modules/application/application.js:309:9
3 bootstrapNativeScriptApp@file:///app/tns_modules/nativescript-angular/platform-common.js:205:22
4 bootstrapApp@file:///app/tns_modules/nativescript-angular/platform-common.js:106:34
5 bootstrapModule@file:///app/tns_modules/nativescript-angular/platform-common.js:90:22
6 anonymous@file:///app/main.js:8:57
7 evaluate@[native code]
8 moduleEvaluation@:1:11
9 promiseReactionJob@:1:11
)
2019-07-02 12:00:03.681 nsplaydev[1064:606206] *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: TypeError: undefined is not a function (near '...cv._eachLayoutView...')
at
1 @file:///app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:134:25
2 eachChildView@file:///app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:125:28
3 eachLayoutChild@file:///app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:133:23
4 onMeasure@file:///app/tns_modules/tns-core-modules/ui/layouts/grid-layout/grid-layout.js:107:25
5 measure@file:///app/tns_modules/tns-core-modules/ui/core/view/view.js:55:21
6 measureChild@file:///app/tns_modules/tns-core-modules/ui/core/view/view-common.js:929:20
7 onMeasure@file:///app/tns_modules/tns-core-modules/ui/action-bar/action-bar.js:302:44
8 measure@file:///app/tns_modules/tns-core-modules/ui/core/view/view.js:55:21
9 layoutInternal@file:///app/tns_modules/tns-core-modules/ui/action-bar/action-bar.js:132:17
10 update@file:///app/tns_modules/tns-core-modules/ui/action-bar/action-bar.js:202:26
11 onLoaded@file:///app/tns_modules/tns-core-modules/ui/page/page.js:240:28
12 @file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:311:93
13 callFunctionWithSuper@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:304:9
14 callLoaded@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:311:31
15 loadView@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:439:22
16 _addViewCore@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:434:20
17 _addView@file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:420:22
18 viewWillAppear@file:///app/tns_modules/tns-core-modules/ui/page/page.js:81:23
19 UIApplicationMain@[native code]
20 _start@file:///app/tns_modules/tns-core-modules/application/application.js:277:22
21 run@file:///app/tns_modules/tns-core-modules/application/application.js:309:9
22 bootstrapNativeScriptApp@file:///app/tns_modules/nativescript-angular/platform-common.js:205:22
23 bootstrapApp@file:///app/tns_modules/nativescript-angular/platform-common.js:106:34
24 bootstrapModule@file:///app/tns_modules/nativescript-angular/platform-common.js:90:22
25 anonymous@file:///app/main.js:8:57
26 evaluate@[native code]
27 moduleEvaluation@[native code]
28 promiseReactionJob@[native code]
', reason: '(null)'
*** First throw call stack:
(0x18fbdd27c 0x18edb79f8 0x1013477f4 0x101378db4 0x101dddfa4 0x101de01b4 0x1bbdfb6e4 0x1bbdfbdb0 0x1bbd53578 0x1bbd674b8 0x1bbd688e0 0x1bbd4baf0 0x1bc836ed0 0x194091a20 0x1940969c8 0x193ff92d0 0x194027330 0x194027f20 0x18fb6e5f8 0x18fb69320 0x18fb6989c 0x18fb690b0 0x191d6979c 0x1bc39f978 0x101de0044 0x101ddd6c4 0x101ddd1c0 0x10130cb80 0x101ddc268 0x101ddb6c4 0x101ddb6c4 0x101ddb6c4 0x101ddb6c4 0x101ddb6c4 0x101ddb6c4 0x101dd412c 0x101bd4abc 0x101d8e520 0x101324570 0x101463268 0x101ddc13c 0x101ddb6c4 0x101ddb6c4 0x101dd412c 0x101bd4abc 0x101d8e684 0x10145e668 0x10131b90c 0x101385930 0x10115db14 0x100a833f0 0x18f62e8e0)
libc++abi.dylib: terminating with uncaught exception of type NSException
2019-07-02 12:00:03.682 nsplaydev[1064:606206] PlayLiveSync: Uncaught Exception

总而言之,在为iOS编译时,NativeScript中出现了一些错误:

2019-07-02 11:59:59.676 nsplaydev[1064:606206] JavaScript error:
file:///app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:134:25: JS ERROR TypeError: undefined is not a function (near '...cv._eachLayoutView...')

自从我在Windows上进行开发以来,我无法调试iphone,尝试使用osx vmware映像,但是Sidekick在其中无法正常运行...

1 个答案:

答案 0 :(得分:0)

nsRouterLink无关,该错误实际上在您的child.component.html上的代码中

<ActionBar class="action-bar">
    <GridLayout rows="auto" columns="*">
        <NavigationButton icon="res://back" tap="onDrawerButtonTap"></NavigationButton>
        <Label row="0" horizontalAlignment="center" text="This be child"></Label>
    </GridLayout>
</ActionBar>

<Button text="child works!"></Button>

您不能将NavigationButton放在自定义布局中,它应该是ActionBar的直接子元素,因此下面的代码应该可以工作

 <ActionBar class="action-bar">
      <NavigationButton icon="res://back" tap="onDrawerButtonTap"></NavigationButton>
    <GridLayout rows="auto" columns="*">
        <Label row="0" horizontalAlignment="center" text="This be child"></Label>
    </GridLayout>
</ActionBar>

<Button text="child works!"></Button>