在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 {
}
答案 0 :(得分:0)
这里发生了同样的事情。我已经通过创建一个与组件同名的模块并添加了NgModule NO_ERRORS_SCHEMA来解决了这个问题。
类似的东西:
@NgModule({
schemas: [
NO_ERRORS_SCHEMA
],
bootstrap: [
AppComponent
],
imports: [
CommonModule,
NativeScriptModule,
...
],
declarations: [...],
providers: [...]
})
export class ProfileModule {
}
,然后将其导入到app.module。