NativeScript 错误 NG8001:“ActionBar”不是已知元素

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

我的startupscreen.module.ts看起来像这样:

import { NativeScriptFormsModule } from "@nativescript/angular";
import { NativeScriptCommonModule } from "@nativescript/angular/common";
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { StartupscreenComponent } from "./startupscreen.component";


@NgModule({
  imports: [
    NativeScriptFormsModule,
    NativeScriptCommonModule
  ],
  declarations: [
    StartupscreenComponent
  ],
  schemas: [
    NO_ERRORS_SCHEMA
  ],
})
export class StartupscreenModule { }

我的 app.module.ts 看起来像这样:

import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptFormsModule, NativeScriptModule } from "@nativescript/angular";
import { FormsModule} from '@angular/forms'

import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { BrowserModule } from '@angular/platform-browser';
import { StartupscreenModule } from "./startupscreen/startupscreen.module";

@NgModule({
    bootstrap: [
        AppComponent
    ],
    imports: [
        FormsModule,
        BrowserModule,
        NativeScriptModule,
        NativeScriptFormsModule,
        AppRoutingModule,
        NativeScriptFormsModule,
        StartupscreenModule,
    ],
    declarations: [
        AppComponent
    ],
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})
export class AppModule { }

我在编译时总是遇到这个错误。 一切都应该运行。

我的路径如下所示:

enter image description here

完整错误:

ERROR in ./app/startupscreen/startupscreen.module.ts
Module not found: Error: Can't resolve '@nativescript/angular/common' in 'E:\Users\SwaX\Desktop\MorseChat\src\app\startupscreen'
 @ ./app/startupscreen/startupscreen.module.ts 2:0-72 11:12-36 14:8-32 20:20-44
 @ ./app/app.module.ts
 @ ./main.ts
Error from chokidar (E:\): Error: EBUSY: resource busy or locked, lstat 'E:\swapfile.sys'
(node:11364) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat 'E:\Users\Default User'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11364) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 7)
(node:11364) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

当我删除 app.module.ts 中的 Startupscreen 后,它说找不到。

startupscreen.component.html:

<ActionBar title="Startupscreen">
    <NavigationButton (tap)="onBackTap()" android.systemIcon="ic_menu_back"></NavigationButton>
</ActionBar>

<StackLayout class="page">
    <StackLayout class="box box-1">
        <Label textWrap="true" text="Bitte hier klicken wenn Sie sehen können."></Label>
    </StackLayout>
    <StackLayout class="box box-2">
        <Label textWrap="true" text="Bitte hier klicken wenn Sie Taubblind sind."></Label>
    </StackLayout>
</StackLayout>
node.js angular typescript nativescript
2个回答
1
投票

我相信

NativescriptCommonModule
的路径只是
@nativescript/angular
类似于
NativeScriptFormsModule

import { NativeScriptCommonModule } from "@nativescript/angular";

0
投票

在我的例子中,产生这个错误是因为我错过了 app.module.ts 中的组件声明(属性声明)

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