【问题标题】:JsTree gives Property 'jstree' does not exist on type 'JQuery<HTMLElement>' in Angular 4JsTree 给属性 'jstree' 在 Angular 4 中的类型'JQuery<HTMLElement>' 上不存在
【发布时间】:2019-09-12 05:40:30
【问题描述】:

我正在使用 Angular 4,我想在我的应用程序中使用 JsTree。我将 JsTree 集成到我的 Angular 应用程序中,就像在这个答案中一样:How to add jstree to angular 2 application using typescript with @types/jstree

当我运行ng serve 时出现以下错误

ERROR in D:/VsCodeProjects/float-client/src/app/dashboard/budget-setup/budget-setup.component.ts (27,15): Property 'jstree' does not exist on type 'JQuery<HTMLElement>'.

ERROR in D:/VsCodeProjects/float-client/src/app/dashboard/budget-setup/budget-setup.component.ts (27,15): Property 'jstree' does not exist on type 'JQuery<HTMLElement>'.

在component.ts中

ngOnInit() {
    $('#foo').jstree();
}

在component.html中

<div id="foo">
  <ul>
    <li>Root node 1
      <ul>
        <li>Child node 1</li>
        <li><a href="#">Child node 2</a></li>
      </ul>
    </li>
  </ul>
</div>

jstree 是否仍然支持 Angular 4?如果支持,我在这里缺少什么?

【问题讨论】:

标签: angular jstree


【解决方案1】:

你也可以使用:-

  let elem: any;
    elem = $("#foo");
    elem.jstree();

【讨论】:

  • 我得到 TypeError: elem.jstree is not a function in browser console。我已经在 angular-cli.json 中包含了脚本和样式
猜你喜欢
  • 1970-01-01
  • 2018-03-08
  • 2020-01-17
  • 1970-01-01
  • 1970-01-01
  • 2017-12-15
  • 2018-06-21
  • 2020-02-16
  • 2020-04-08
相关资源
最近更新 更多