我正在关注官方教程。我现在卡在第3章。我得到像这样的日志非常奇怪
Successfully transferred app.routing.ts.
Successfully transferred app.module.ts.
Successfully transferred app.module.js.
Refreshing application...
Successfully synced application org.nativescript.Groceries on device 2CB64AE2-E31B-4B15-ACA5-B501400C2814.
1 0x10dac0d4b NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2 0x10e16428e ffi_closure_unix64_inner
3 0x10e164bd2 ffi_closure_unix64
4 0x1107f2245 -[UIViewController __viewWillAppear:]
5 0x110833aa2 -[UINavigationController _startTransition:fromViewController:toViewController:]
6 0x11083492f -[UINavigationController _startDeferredTransitionIfNeeded:]
7 0x110835b90 -[UINavigationController __viewWillLayoutSubviews]
8 0x110a8c2ae -[UILayoutContainerView layoutSubviews]
9 0x11071c551 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
10 0x1147524ba -[CALayer layoutSublayers]
11 0x1147565a9 CA::Layer::layout_if_needed(CA::Transaction*)
12 0x1146df1cd CA::Context::commit_transaction(CA::Transaction*)
13 0x11470aae4 CA::Transaction::commit()
14 0x110669706 __34-[UIApplication _firstCommitBlock]_block_invoke_2
15 0x11282c20c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
16 0x112810a3b __CFRunLoopDoBlocks
17 0x112810214 __CFRunLoopRun
18 0x11280fa89 CFRunLoopRunSpecific
19 0x1140179c6 GSEventRunModal
20 0x11064dd30 UIApplicationMain
21 0x10e164a2d ffi_call_unix64
22 0x1353bbc60
file:///app/tns_modules/nativescript-angular/resource-loader.js:23:101: JS ERROR Error: File /Users/zhouyuan/Library/Developer/CoreSimulator/Devices/2CB64AE2-E31B-4B15-ACA5-B501400C2814/data/Containers/Bundle/Application/C64D6180-4E51-4808-9AD5-09E0B329379A/Groceries.app/app/pages/login/pages/login/login.html does not exist. Resolved from: /Users/zhouyuan/Library/Developer/CoreSimulator/Devices/2CB64AE2-E31B-4B15-ACA5-B501400C2814/data/Containers/Bundle/Application/C64D6180-4E51-4808-9AD5-09E0B329379A/Groceries.app/app/pages/login/pages/login/login.html.
我很确定它应该是/app/pages/login/login.html
,但错误说app/pages/login/pages/login/login.html.
任何人都知道为什么会这样?
答案 0 :(得分:1)
我猜你正在使用angular-nativescript看到app.routing.ts
在login.ts中,您可以定义组件,如:
@Component({
selector: "my-app",
moduleId: module.id,
templateUrl: "./login.html"
})
或
@Component({
selector: "my-app",
templateUrl: "pages/login/login.html",
})
如果您想使用相对路径,请添加moduleId: module.id
答案 1 :(得分:0)
更改组件名称时,请仔细检查是否更改了所有内容。我错过了更改该组件的html和css名称的方法。
在 templateUrl 和 styleUrls 下面,我忘记了更改名称。这就是我遇到的错误。
@Component({
selector: "my-modal",
templateUrl: "pages/address.modal.html",
styleUrls: ["pages/address.modal.css"]
})