angular - 当我将“changeDetectionStrategy”添加到我的应用程序时出现错误
问题描述
我正在前端使用 Angular7 构建我的第一个 CRUD、Spring/hib。当我尝试在我的 component.ts 中添加 changeDetectionStrategy 时,我收到以下警告:
WARNING in ./node_modules/@angular/compiler/src/core.js
10:24-31 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
WARNING in ./node_modules/@angular/compiler/src/selector.js
10:24-31 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
WARNING in ./node_modules/@angular/compiler/src/ml_parser/html_tags.js
10:24-31 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
WARNING in ./node_modules/@angular/compiler/src/ml_parser/tags.js
10:24-31 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted.
该应用程序还有其他可以正常工作的组件,并且它们具有 changeDetectionStrategy 导入。当我将该方法添加到我的组件时,角度会给我这些错误。我评论了所有组件,除了@Component 的东西和“导出类 XY { }。错误一直存在,直到我删除 changeDetectionStrategy。知道它可能是什么吗?
解决方案
我认为这是由于 changeDetectionStrategey 的错误导入
import { ChangeDetectionStrategy } from '@angular/compiler/src/core';
用正确的替换它
import { ChangeDetectionStrategy } from '@angular/core';
推荐阅读
- java - 扩展数学表达式(扩展括号)
- sql - 带总和的案例陈述
- python - numpy.memmap 无法处理非常大的数据
- android - 如何在 Kotlin 中定义多个变量
- json - 使用 JSON 对象作为 DataSource 在 DataGridView 列中显示图像
- sql - 在动态查询中插入临时表中的数据
- sql - 如何在 Objection/Knex 中使用“joinEager”和原始 sql 查询?
- javascript - Webassembly - 是否可以从 API 获取/获取 JSON 数据并在 JS 中进行操作?
- api - 从实时 Fixer api 货币数据填充 Highchart 折线图
- python - 如何在 pandas 中获得组中最受欢迎的项目?