如何在 Angular 7 中使用 Jquery 第三方插件



我在 Angular 7 项目中添加了 jquery 和 jquery 第三方插件"stiffChart"。我已经在我的项目中安装了jquery和插件。在angular.json文件中声明相同的内容,但是在调用插件方法时,我收到以下错误。

错误: [ts] 属性"僵硬图表"在类型"JQuery"上不存在

我的代码:

import { Component, OnInit } from '@angular/core'; 
import * as $ from'jquery';
interface JQuery {   stiffChart(options?: any): any; }
@Component({   
    selector: 'app-demo',   templateUrl:   './demo.component.html',   
    styleUrls: ['./demo.component.css'] })
    export class DemoComponent implements OnInit {
    constructor() { }
    ngOnInit() {
     $('#your-chart-name').stiffChart({});
 }}

请让我知道我在这里做错了什么。

你需要在 angular.json 文件中包含 jquery 和插件的脚本。

最新更新