【问题标题】:Directives SUDDENLY not recognized in @Component@Component 中突然无法识别指令
【发布时间】:2017-01-09 16:55:48
【问题描述】:

由于某种原因,@component 元数据的 directives 属性无法识别,红色下划线..

导致我的组件无法加载,浏览器控制台尖叫:

'account-transactions' is not a known element:

非常感谢任何帮助,似乎无法弄清楚发生了什么。

提前致谢。

【问题讨论】:

    标签: angular components webstorm


    【解决方案1】:

    我假设您已更新到 RC.6

    directivespipes 在 RC.5 中已弃用并在 RC.6 中删除

    @NgModule() 中改用declarations

    【讨论】:

    • 我确实删除了 node_modules 并再次安装了 npm 但我怎么突然进入 RC6?我的 package.json 保持不变,使用 RC6 您现在在 app.module 中声明所有组件,而不是在使用特定组件的每个组件中声明? (希望我的句子有道理)
    • 我猜您没有修复版本约束,但允许版本范围。您需要创建模块并将指令、组件和管道分配给恰好一个 NgModule。如果您想在另一个 NgModule 中使用其中一个,请将模块添加到 @NgModule({imports: [...] })`
    • 你完全正确! ,我在 package.json 的每个 @angular/XXXX 依赖项上都有 ^,删除它解决了它,现在 directives 被识别。
    • 超出了这个问题的范围,我应该使用declarations 并将directives 放在一边吗?
    • 当然。如您所见,directives 已经消失了。
    猜你喜欢
    • 2019-12-01
    • 2016-08-30
    • 1970-01-01
    • 1970-01-01
    • 2019-08-27
    • 2017-06-09
    • 1970-01-01
    • 1970-01-01
    • 2019-12-26
    相关资源
    最近更新 更多