【问题标题】:How to use Jquery third party plugin with Angular 7?如何在 Angular 7 中使用 Jquery 第三方插件?
【发布时间】:2019-01-11 13:48:12
【问题描述】:

我在 Angular 7 项目中添加了 jquery 和 jquery 第三方插件“stiffChart”。我已经在我的项目中安装了 jquery 和插件。在 angular.json 文件中声明相同但在调用插件方法时出现以下错误。

错误:[ts] 类型“JQuery”上不存在属性“stiffChart”

我的代码:

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

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

【问题讨论】:

  • 请提及反对反对票的观点..
  • 嗨,你解决了这个问题吗?我也遇到了同样的问题

标签: jquery angular jquery-plugins angular7


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2023-03-17
    • 2019-12-16
    • 1970-01-01
    • 1970-01-01
    • 2019-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多