【问题标题】:Angular 4 cannot find name 'ViewChild'Angular 4 找不到名称“ViewChild”
【发布时间】:2018-03-30 17:04:46
【问题描述】:

我遇到了这个奇怪的错误,没有找到类似的东西.. 我在我的网站上使用 ng2-canvas-whiteboard 组件作为绘图画布,一切工作正常,除非我尝试使用以下方法引用该画布:

@ViewChild('canvasWhiteboard') canvasWhiteboard: CanvasWhiteboardComponent;

正如官方文档建议的那样,我收到了这个错误:

Failed to compile.

e:/frontend/src/app/components/user/dashboard/dashboard.component.ts (15,2): Cannot find name 'ViewChild'.

有什么建议吗?谢谢

【问题讨论】:

    标签: angular find viewchild


    【解决方案1】:

    使用前忘记导入ViewChild

    import { ViewChild } from '@angular/core'
    

    【讨论】:

      猜你喜欢
      • 2017-09-14
      • 1970-01-01
      • 2018-02-02
      • 2017-09-18
      • 2016-01-24
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多