刚刚从 ng8 升级到 ng11。当我运行 ngserve 时它工作正常,但是当我运行 build 进行生产时我收到以下错误:
生成用于差异加载的 ES5 包...发生未处理的异常:C:\P.....\src\app\9-es2015.dce42a686e45767441f2.js: 无法读取未定义的属性“split”
我尝试删除代码以查看导致问题的原因,并在组件中找到以下代码,我将枚举更改为它可以工作的硬编码数字,或者如果删除 console.log。看来是es2015的问题,改成es5解决了。
import {FormTableData} from '../../../form/service/type/form-table-data';
import {FormFieldTypes} from '../../../form/service/type/form-field-types.enum';
export class FormEditorFormData {
formData: FormTableData;
fieldType = FormFieldTypes;
arr: string[];
constructor(n: number,s:string) {
let type = 0;
const option: string[] = [];
for (const s of this.arr) {
if (s != null) {
switch (type) {
case FormFieldTypes.checkbox:
const cap = 'pp';
option.forEach( (currentValue) => {
console.log(cap);
});
break;
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
表单字段类型:
export enum …Run Code Online (Sandbox Code Playgroud) 我有下面的代码示例。如何确保对于任何给定的行数或列数,网格将根据需要扩展项目以填充其父容器?
目的是拥有一种计算器应用程序,其中网格项目作为按钮,应占用尽可能多的空间但均匀。
以下是我带来的。正如您所看到的,有滚动,而且我不确定这是正确的方法。
body {
min-height: 100%;
}
.wrapper {
display: grid;
position: relative;
grid-template-columns: repeat(6, 1fr);
grid-template-rows: repeat(2, 1fr);
grid-gap: 1px;
justify-content: center;
height: 100%;
}
.box {
background-color: #444;
color: #fff;
border-radius: 5px;
padding: 20px;
font-size: 12px;
}
.container {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
position: absolute;
}Run Code Online (Sandbox Code Playgroud)
<section class="container">
<div class="wrapper">
<div class="box a">A</div>
<div class="box b">B</div>
<div class="box c">C</div>
<div class="box d">D</div>
<div class="box e">E</div>
<div class="box f">F</div>
<div class="box a">A</div>
<div class="box …Run Code Online (Sandbox Code Playgroud)我在我的项目中遇到了一个非常奇怪的行为,我有一个简单的 Angular 服务,代码如下:
seatClick$ = new Subject<Seat>();
Run Code Online (Sandbox Code Playgroud)
以及服务上触发 observable 的方法:
handleSeatClick(seat: Seat) {
this.seatClick$.next(seat);
}
Run Code Online (Sandbox Code Playgroud)
可观察到的逻辑很简单:
this.seatClick$.pipe(
exhaustMap((seat: Seat) => {
this.someFunctionThatThrowsException(); // this function throws ref exception
return of(null);
})
, catchError(err => {
console.log('error handled');
return of(null);
})
)
.subscribe(() => {
console.log('ok');
},
(error1 => {
console.log('oops');
})
);
Run Code Online (Sandbox Code Playgroud)
这真的很奇怪,当调用“someFunctionThatThrowsException”时,它会抛出一些ReferenceError异常,然后用catchError捕获该异常并触发next()事件。
然而,从此时开始,seatClick observable 停止响应,就好像它已经完成一样,在服务上调用handleSeatClick 将不再响应。
我在这里缺少什么?
angular ×2
typescript ×2
css ×1
css-grid ×1
ecmascript-5 ×1
ecmascript-6 ×1
observable ×1
rxjs ×1