angular - 当我在 Angular 9 中运行 npm start 时出现“内部错误中的错误:意外的插值”错误
问题描述
运行时出现此错误npm start
:
[HPM] Subscribed to http-proxy events: [ 'error', 'close' ]
chunk {main} main.js, main.js.map (main) 2.16 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 722 bytes [initial] [rendered]
chunk {polyfills-es5} polyfills-es5.js, polyfills-es5.js.map (polyfills-es5) 518 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 711 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 882 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 340 kB [initial] [rendered]
Date: 2020-02-15T13:20:57.999Z - Hash: ddcf910bd445ac9ea9a0 - Time: 8343ms
ERROR in Internal Error: Unexpected interpolation
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
解决方案
这也发生在我身上,我通过更新我的 tsconfig 来解决它。这让我可以看到阻止构建完成的 html 错误。这是我修改的
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"strictTemplates": true
}
更新 修复所有明显的html错误后,错误仍然存在,经过广泛的研究,我发现了这个git问题 问题出在我的html中,我有这行:
style="background-image: {{currentuser.profile.photoURL}}"
这通常不是一个好的做法,删除此行会立即清除错误。如果有人遇到同样的问题,我建议查看这个答案。
就我而言,我只是将上面的行更改为
[style.background-image]="currentuser.profile.photoURL"
像魅力一样工作
推荐阅读
- jenkins - 即使量角器测试用例失败,如何防止詹金斯管道通过并继续构建
- javascript - SyntaxError: 不能在模块外使用 import 语句
- azure - Camel-Azure BlobStreamAndLength IllegalArgumentException:不支持的 blob 类型:org.apache.camel.component.file.remote.SftpRemoteFileJCraft
- r - 在传单 R 中创建最小网格
- javascript - 自定义函数将 Vue.js 数据值更改为副作用
- python - Django 从查询集中获取查询。返回无效参数
- jestjs - 如何配置 jest 来处理 SvelteKit 的 `$lib` 别名?
- spring-cloud - 如何将 DefaultMessageListenerContainer 与 Spring 的 SqsListener 一起使用?
- mule-studio - Scatter-Gather 中的错误处理 (Mule 4)
- git - 为什么使用高延迟网络时 git 很慢