未捕获的TypeError:Object(...)不是函数

时间:2019-09-23 13:28:49

标签: angular leaflet

我必须在我的angular 7项目中使用leaflet-pixi-overlay库,所以 我已经安装并导入了https://github.com/manubb/Leaflet.PixiOverlay中引用的所需库:

import * as PIXI from 'pixi.js';
import {pixiOverlay} from 'leaflet-pixi-overlay';

当我像这样调用库函数时:

147 - const a = pixiOverlay(
148 -       (utils) =>  {
149 -      // your drawing code here
150 - }, new PIXI.Container());

我收到以下错误:

zone.js:192 Uncaught TypeError: Object(...) is not a function
at MapComponent.push../src/app/modules/map/components/map/map.component.ts.MapComponent.ngOnInit (map.component.ts:147)
at checkAndUpdateDirectiveInline (core.js:18668)
at checkAndUpdateNodeInline (core.js:19932)
at checkAndUpdateNode (core.js:19894)
at debugCheckAndUpdateNode (core.js:20528)
at debugCheckDirectivesFn (core.js:20488)
at Object.eval [as updateDirectives] (VisionClientComponent.html:17)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:20480)
at checkAndUpdateView (core.js:19876)
at callViewAction (core.js:20117)

有任何线索吗?谢谢

1 个答案:

答案 0 :(得分:2)

leaflet-pixi-overlay库不导出任何内容。它使用leaflet方法扩展了pixiOverlay库。因此,只需导入leaflet-pixi-overlay库,然后从pixiOverlay库导入leaflet

import 'leaflet-pixi-overlay';
import { pixiOverlay } from 'leaflet';