我试图在我的angular应用程序中使用一个javascript库,但是这样做有些麻烦。
复制步骤:
(npm install jquery-保存)
(npm install --save @ types / jquery)
在我的ts文件中,我添加了以下导入
从'jquery'中将*导入为$;
将我要使用的库文件的位置添加到我的angular.json文件中
“脚本”:[ “ ./node_modules/mapael/england_counties.js”, “ ./node_modules/mapael/jquery.mapael.min.js”, “ ./node_modules/mapael/raphael.min.js” ]
TS文件:
import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
@Component({
selector: 'app-interactive-map',
templateUrl: './interactive-map.component.html',
styleUrls: ['./interactive-map.component.scss']
})
export class InteractiveMapComponent implements OnInit {
constructor() { }
ngOnInit() {
$(".mapcontainer").mapael(
{
"map": {
"name" : "england_counties",
"zoom": {
"enabled": true,
"maxLevel": 5
}
}
})
}
}
我目前收到以下错误消息:
类型“ JQuery”上不存在属性“ mapael”。
任何人都可以帮忙。