【问题标题】:Uncaught TypeError: Object(...) is not a function未捕获的 TypeError:Object(...) 不是函数
【发布时间】:2019-09-23 23:04:11
【问题描述】:

我必须在我的 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)

有什么线索吗?谢谢

【问题讨论】:

  • 你能把代码贴在 map.component.ts 第 147 行吗?
  • ngOnInit(): void { const a = pixiOverlay( (utils) => { // your drawing code here }, new PIXI.Container()); // Permet de recentrer la map quand on slide sur la gauche if (this.onComponentResize) { this.onComponentResize.subscribe(() => { if (this.map) { this.map.invalidateSize(); } }); } }
  • 对不起,我无法格式化上一条评论中的代码
  • 第147行是哪一个:pixiOverlayPIXI.Container()
  • pixiOverlay 是行

标签: angular leaflet


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2018-04-22
    • 1970-01-01
    • 2018-11-05
    • 2020-04-15
    • 2020-06-04
    • 2019-08-06
    • 2011-09-13
    • 2017-07-20
    • 2019-09-26
    相关资源
    最近更新 更多