【问题标题】:Can't bind to 'theme' since it isn't a known property of 'jqxTree'无法绑定到“主题”,因为它不是“jqxTree”的已知属性
【发布时间】:2019-02-26 13:23:48
【问题描述】:

在运行以下代码并配置一些设置后,我在 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"
    ]

现在似乎一切正常我想知道问题是什么??!!!

【问题讨论】:

  • 确保AppModule 是最接近该组件的模块,否则,如果您有多个模块,请在最近/共享模块中声明jqxTreeComponent
  • 你把对应的模块加载到app模块了吗?

标签: angular angular7 jqxtree


【解决方案1】:

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

  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. 在 tsconfig.json 文件中 compilerOptions 属性后添加以下配置:

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

【讨论】:

    猜你喜欢
    • 2017-06-21
    • 2017-02-03
    • 1970-01-01
    • 2019-10-10
    • 1970-01-01
    • 1970-01-01
    • 2019-08-26
    • 2017-09-17
    • 2018-02-19
    相关资源
    最近更新 更多