我ResizeObserver在我的组件中使用过,它工作正常。但是运行ut时出现这样的错误:
ReferenceError: ResizeObserver is not defined
133 | });
134 |
> 135 | this.resizeObserver = new ResizeObserver((entries) => {
| ^
136 | const entry = entries.find((e) => e.target === this.wrapper._elementRef.nativeElement);
137 | if (entry && entry.contentRect) {
138 | if (this.select && this.select.isOpen) {
Run Code Online (Sandbox Code Playgroud)
我使用 TestBed 创建组件:
fixture = TestBed.createComponent(MyComponent);
Run Code Online (Sandbox Code Playgroud)
我不明白为什么会出现这个错误,我只是新建了一个对象。
ts 版本
"rxjs": "~6.5.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
我尝试以java.time.LocalDate两种方式序列化包含的对象,但都失败了。
@JsonUnwrapped并@JsonFormat(shape=JsonFormat.Shape.STRING)得到错误:
线程“main”com.fasterxml.jackson.dataformat.csv.CsvMappingException 中的异常:CSV 生成器不支持属性(嵌套对象)的对象值(通过引用链:java.util.ArrayList[0]->models.DateRange[ "完成"]->java.time.LocalDate["chronology"])
@Data
@AllArgsConstructor
@NoArgsConstructor
//@JsonFormat(shape=JsonFormat.Shape.STRING)
public class DateRange {
@JsonUnwrapped
@JsonFormat(shape=JsonFormat.Shape.STRING)
private LocalDate start;
@JsonUnwrapped
@JsonFormat(shape=JsonFormat.Shape.STRING)
private LocalDate finish;
}
--------
public class CsvPractice {
public static void main(String[] args) throws JsonProcessingException {
ArrayList<DateRange> csv = Lists.newArrayList();
for (int i = 1; i < 6; i++) {
csv.add(new DateRange(LocalDate.now().plusDays(i), LocalDate.now().plusDays(i + 1)));
}
CsvMapper mapper = new CsvMapper();
// mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
CsvSchema schema = mapper.schemaFor(DateRange.class).withHeader();
System.out.println(mapper.writer(schema).writeValueAsString(csv));
}
}
Run Code Online (Sandbox Code Playgroud)
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); …