我正在尝试使用传单的热图库来构建我的 Angular 9 项目。 编译时效果很好,但是当我尝试 --prod build 时,出现以下错误:
heat-map-map.component.ts 中的错误:112:7 - 错误 TS2339:类型“typeof import("projectPath/ClientApp/node_modules/@types/leaflet/index")”上不存在属性“heatLayer”。这是我的代码:
var convertedData: [number, number, number][];
convertedData = this.grid.map(g => [g.lat, g.lon, this.data.find(d => d.toID == g.gid)?.time_sec]);
// THIS is the important line
L.heatLayer(convertedData, { max: max.time_sec }).addTo(this.markersLayer);
this.markersLayer.addTo(this.map);
和我的进口:
import * as L from 'leaflet'
import 'leaflet.heat/dist/leaflet-heat.js';
谢谢你
import * as L from 'leaflet';
import 'leaflet.heat';
注意:我不需要向 angular.json 脚本数组添加任何内容