0

在运行以下代码并配置一些设置后,我在 Angular 7 中使用 jqxTreeComponent,我在执行 ng serve 时遇到此错误。

npm install jqwidgets-scripts --save

执行 ng serve 时出现此错误。 在此处输入图像描述 这是我的组件模板代码:

 <div class="tree-container">
          <jqxTree class="tree-container--item" [theme]="'material'" #myTree [width]="300" [height]="450" [source]="records"
            [rtl]="true">
          </jqxTree>
          <div class="tree-container--item">
            <div fxLayout="row">
              <jqxButton [theme]="'material'" (onClick)="AddNode($event)" [width]="125" [height]="25">add</jqxButton>
              <input [(ngModel)]="nodeName"  *ngIf="showTextBox" placeholder="add" />
            </div>
</div>

此外,我在组件的 ts 文件中添加了以下代码(当然在正确的位置!!)

import { jqxTreeComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxtree';
@ViewChild('myTree') myTree: jqxTreeComponent;

除了这一步,我在 app.module.ts 文件的 decleration 部分添加了两个组件:

import { jqxButtonComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxbuttons';
import { jqxTreeComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxtree';


  jqxButtonComponent, jqxTreeComponent

作为最后一步,我将以下代码添加到我的 tscodfig 文件中:

 "include": [
        "src/**/*"
    ],
    "files": [
        "src/app/app.module.ts",
        "node_modules/jqwidgets-scripts/jqwidgets-ts/angular_jqxbuttons.ts",
        "node_modules/jqwidgets-scripts/jqwidgets-ts/angular_jqxtree.ts"
    ]

一切似乎都是正确的,我想知道是什么问题??!!!

4

1 回答 1

0

我有一些建议,请尝试,希望对您有所帮助

  1. 制作一个 JqxWidgetsModule

    从'jqwidgets-scripts/jqwidgets-ts/angular_jqxbuttons'导入{jqxButtonComponent};
    从'jqwidgets-scripts/jqwidgets-ts/angular_jqxtree'导入{jqxTreeComponent};

    @NgModule({
    声明: [ jqxButtonComponent, jqxTreeComponent],
    导出: [ jqxButtonComponent, jqxTreeComponent]
    })
    导出类 JqxWidgetsModule { }

在您的 LocationModule 中导入此模块

    @NgModule({
  declarations: [...],
  imports: [
    CommonModule,
    LocationRoutingModule,
    JqxWidgetsModule
  ]
})
export class LocationModule { }
  1. 在 compilerOptions 属性后的 tsconfig.json 文件中添加以下配置:

    "include": [ "src/**/*.ts", "node_modules/jqwidgets-scripts/jqwidgets-ts/angular_jqxbuttons.ts", "node_modules/jqwidgets-scripts/jqwidgets-ts/angular_jqxtree.ts" ]

于 2019-03-21T07:03:35.647 回答