简体   繁体   中英

How to use Jquery third party plugin with Angular 7?

I have added jquery and a jquery third party plugin " stiffChart " with my Angular 7 project. I have install jquery and the plugin in my project. Declare the same in angular.json file but while calling the plugin method I am getting the following error.

Error: [ts] Property 'stiffChart' does not exist on type 'JQuery'

My code:

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({});
 }}

Please let me know what is wrong I am doing here.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM