jquery - Angular 6 导入 JQVMap - 类型“JQuery”上不存在属性“vectorMap”'
问题描述
我正在尝试将可点击的地图、JQVMap和 JQuery 导入到我的 Angular 6 项目中,但我遇到了一些初期问题。
例外:错误 TS2339:“JQuery”类型上不存在属性“vectorMap”。
我的组件:
import {AfterViewInit, Component} from '@angular/core';
import * as jQuery from 'jquery';
@Component({
selector: 'app-example',
templateUrl: './explore.component.html'
})
export class ExampleComponent implements AfterViewInit {
ngAfterViewInit() {
jQuery('#vmap').vectorMap(
{
map: 'world_en',
backgroundColor: '#a5bfdd',
borderColor: '#818181',
borderOpacity: 0.25,
borderWidth: 1,
color: '#f4f3f0',
enableZoom: true,
hoverColor: '#c9dfaf',
hoverOpacity: null,
normalizeFunction: 'linear',
scaleColors: ['#b6d6ff', '#005ace'],
selectedColor: '#c9dfaf',
selectedRegions: null,
showTooltip: true
});
}
}
我已经通过 npm 和 assets 目录中的必要 JVQMap 脚本安装了 JQuery。JQuery 似乎工作正常。
角.json
"scripts": ["./node_modules/jquery/dist/jquery.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.js",
"./src/assets/js/jquery.vmap.js",
"./src/assets/js/jquery.vmap.world.js"]
},
如果这是一个微不足道或愚蠢的错误,我们深表歉意。我一般是 Angular 和 JS 的新手
解决方案
用这个
import { Component, OnInit } from '@angular/core';
declare const jQuery: any;
推荐阅读
- apache - Apache/mod_perl 随机失败
- mlr - 如何创建 RLearner_regr_QRNN.R?
- apache-spark - Kappa 架构:当插入到批处理/分析服务层时
- python - 特殊的 eyed3 类型变成了 python 的 NoneType
- pandas - 我可以为 Pandas 列分配多种数据类型吗?
- java - 如何在java中下载unirest post call response?
- php - 如何在php中将字符串与OR运算符连接起来?
- laravel - 如何在不构建自定义工具的情况下实现多对多 nova 资源
- python - 如何修复'TypeError:在方法'MFnMesh_anyIntersection'中,Maya中Python中'MINtArray const *'类型的参数4错误
- hibernate - 多个参数同时搜索 Criteria Api