android - 使用 --env.aot 标志时未构建 Nativescript 应用程序

标签 android angular nativescript android-build angular-aot

当我在 AOT 中构建我的 NS 应用程序时,我遇到了一个奇怪的问题.我正在运行命令tns build android --bundle --release --env.aot <other_key_specific_flags>我正在低于错误。

: 'StackLayout' is not a known element:
1. If 'StackLayout' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
    </FlexboxLayout>
  </StackLayout>
  [ERROR ->]<StackLayout *ngIf="dataEmpty" class="m-25">
    <Label class="fo-24 text-center" text="No Activitie")
: 'StackLayout' is not a known element:
1. If 'StackLayout' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("[ERROR ->]<StackLayout class="a-m-t-25">
  <FlexboxLayout class="app-action-bar" margin="10 5 5 10" justifyCon")


ERROR in ./app/content/profile/profile.component.ts 109:32
Module parse failed: Unexpected token (109:32)
You may need an appropriate loader to handle this file type.
|         core_1.Component({
|             selector: 'ns-profile',
>             /*duleId: module.i*/+ ' ',
|             templateUrl: './profile.component.html',
|             styleUrls: ['./profile.component.scss']
 @ ./app/app.module.ts 33:26-72
 @ ./main.ts

我的 app.module.ts 虽然包含 NO_ERRORS_SCHEMA
...
import { CommonModule } from '@angular/common';
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
...

@NgModule({
  schemas: [
    NO_ERRORS_SCHEMA
  ],
  bootstrap: [
    AppComponent
  ],
  imports: [
    CommonModule,
    NativeScriptModule,
    ...
  ],
  declarations: [...],
  providers: [...]
})
export class AppModule {
}

最佳答案

同样的事情也发生在这里。我通过创建一个与组件同名的模块并添加 NgModule NO_ERRORS_SCHEMA 来解决它。
就像是:

      @NgModule({
     schemas: [
       NO_ERRORS_SCHEMA
     ],
     bootstrap: [
       AppComponent
     ],
     imports: [
       CommonModule,
       NativeScriptModule,
       ...
     ],
     declarations: [...],
     providers: [...]
   })
   export class ProfileModule {
   }
然后将其导入 app.module。

关于android - 使用 --env.aot 标志时未构建 Nativescript 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55294793/

相关文章:

android - 使用 FFmpeg Android 更改音频音量

android - 如何在启动时运行脚本?

Android - 从不同的 Activity 中获取相同的 Intent

css - ngx-image-cropper 样式不起作用

Angular 运行 NG SERVE 出现错误 Cannot find module '@angular/compiler-cli/src/tooling'

javascript - 本地 laravel API 上的 Nativescript-Vue axios 调用错误 [请求失败,状态码为空]

javascript - 如何使用 NativeScript 的 BarcodeScanner 插件

angular - native 脚本异常 : Failed to find module: "crypto"

android - 从代码启动小部件

使用管道或其他方式对数据进行 Angular 美化