You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular 18升级到19后imports属性报错问题咨询

Angular 18升级到19后imports属性报错问题咨询

大家好,我遇到一个Angular升级后的问题想请教下:

我把自己的Angular 18独立组件应用(所有组件原本都配置了standalone: true)通过ng update命令升级到了Angular 19,升级过程中控制台显示:

Updates non-standalone Directives, Component and Pipes to 'standalone:false'
and removes 'standalone:true' from those who are standalone.

目前看起来这一步是正常完成的,所有组件里的standalone: true配置项都被自动移除了。

但是现在Visual Studio Code里,针对我组件代码中的imports: [RouterLink, ...]这部分,一直弹出错误提示:

'imports' is only valid on a component that is standalone.

我实在搞不清楚哪里出问题了,升级的时候我是严格跟着官方的Angular 18到19的升级指南来操作的。

备注:内容来源于stack exchange,提问作者Thomas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 10:34:53