我在下面的代码中运行并配置了一些设置后在角度7中使用jqxTreeComponent,在执行ng服务时遇到此错误。
npm install jqwidgets-scripts --save
<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"
]
现在一切似乎都正确了,我想知道出什么问题了吗?!!!
答案 0 :(得分:0)
我的建议很少,请尝试
制作一个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 { }
在编译器选项属性之后的tsconfig.json文件中添加以下配置:
"include": [
"src/**/*.ts",
"node_modules/jqwidgets-scripts/jqwidgets-ts/angular_jqxbuttons.ts",
"node_modules/jqwidgets-scripts/jqwidgets-ts/angular_jqxtree.ts"
]