I have "ERROR in Internal Error: Unexpected interpolation" error when I run npm start in Angular 9

I have "ERROR in Internal Error: Unexpected interpolation" error when I run npm start in Angular 9

当我 运行 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 issue 问题出在我的 html 中,我有这条线:

style="background-image: {{currentuser.profile.photoURL}}"

这通常不是一个好的做法,删除这一行会立即清除错误。如果有人遇到同样的问题,我建议查看 .

在我的例子中,我只是将上面的行更改为

[style.background-image]="currentuser.profile.photoURL"

工作出色