angular - ng build --prod 工作不正常?如何检查这个?
问题描述
我有一个角度 cli 应用程序。如果我使用ng serve
命令运行它,它工作正常。
ng serve
我没有使用,而是使用了ng build --prod
. 它引发以下脚本错误:
截屏:
我想在生产模式下检查这个应用程序。
在这里,我附上了我的代码:
import { Component, ViewChild, OnInit, ElementRef } from '@angular/core';
import { DialogComponent } from '@syncfusion/ej2-angular-popups';
import { EmitType } from '@syncfusion/ej2-base';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title="test";
@ViewChild('ejDialog') ejDialog: DialogComponent;
// Create element reference for dialog target element.
@ViewChild('container', { read: ElementRef }) container: ElementRef;
// The Dialog shows within the target element.
public targetElement: HTMLElement;
//To get all element of the dialog component after component get initialized.
ngOnInit() {
this.initilaizeTarget();
}
// Initialize the Dialog component target element.
public initilaizeTarget: EmitType<object> = () => {
this.targetElement = this.container.nativeElement.parentElement;
}
// Hide the Dialog when click the footer button.
public hideDialog: EmitType<object> = () => {
this.ejDialog.hide();
}
// Sample level code to handle the button click action
public onOpenDialog = function(event:any): void {
// Call the show method to open the Dialog
this.ejDialog.show();
}
//Animation options
public animationSettings: Object = { effect: 'Zoom', duration: 400, delay: 0 };
// Enables the footer buttons
public buttons: Object = [
{
'click': this.hideDialog.bind(this),buttonModel:{ content:'OK', isPrimary: true }
},
{
'click': this.hideDialog.bind(this),buttonModel:{ content:'Cancel' }
}
];
}
html文件:
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
</div>
<h2>Dialog Component</h2>
<button class="e-control e-btn" style="position: absolute;" id="targetButton" (click)="onOpenDialog($event)">Open Dialog</button>
<div #container class='root-container'></div>
<ejs-dialog id='dialog' #ejDialog header='Dialog' content='Dialog enabled with Zoom effect' [target]='targetElement'
[animationSettings]='animationSettings' width='250px' [buttons]='buttons'>
</ejs-dialog>
如果我使用以下命令,它工作正常:有什么问题?
ng build --prod --no-build-optimizer
解决方案
ng serve --prod --aot=false --build-optimizer=true
推荐阅读
- angular - 如何从网站解析 HTML,例如。计算 Angular 中的单词
- php - PHP - 计算列层次结构中的一些值
- python - 如何在 json 列表中搜索 django
- c# - 无法加载文件或程序集“Microsoft.IdentityModel.Protocols.WsFederation,
- spring - CrudRepository Spring Data @Query 语法
- django - 自定义 wagtail 页面模型保存方法调用了两次
- javascript - 显示从 ajax 操作页面到与 ajax 输出表分开的 ajax 调用页面的总量
- python - 从python中的文本文件中读取特定值
- django - 如果为空,则重做查询集并将信息传递给模板
- java - 返回图像 AWS S3 (S3Object) Spring REST 控制器