【问题标题】:NativeScript Error NG8001: 'ActionBar' is not a known elementNativeScript 错误 NG8001:“ActionBar”不是已知元素
【发布时间】:2021-03-29 10:19:12
【问题描述】:

我的 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 { }

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

我的路径如下所示:

完全错误:

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


    【解决方案1】:

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

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

    【讨论】:

    • 它似乎有所帮助,但现在我收到此错误:错误 NG8001:'ActionBar' 不是已知元素:1. 如果 'ActionBar' 是 Angular 组件,则验证它是否属于这个模块。 2.要允许任何元素添加'NO_ERRORS_SCHEMA'到这个组件的'@NgModule.schemas'
    • 我通过将 StartupscreenComponent 添加到 app.moudle.ts 中的声明来修复它但现在这是新的错误:在设备模拟器 5554 上成功同步应用程序 org.nativescript.morsecat。 System.err:“主”线程上发生未捕获的异常。 System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function
    • 确保 StartuscreenComponent 不是 2 个模块(app.module.ts 和 startupscreen.module.ts)中声明的一部分。
    猜你喜欢
    • 2021-01-27
    • 1970-01-01
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 2021-06-14
    • 2020-06-08
    • 2020-06-19
    • 2021-01-13
    相关资源
    最近更新 更多