如何在ionic 2中使用第三方javascript库(pixijs)?

How to use third-party javascript library (pixijs) in ionic 2?

大家好,我是 Angular JSIonic Framework 的新手,我正在使用最新版本 angular2ionic2.

我想在我的应用程序中使用PixiJs(2D webGL renderer),但我不知道如何添加第三方javascript 库到 Ionic2 app.

以下我已经尝试过:

  1. 安装了第三方库

    npm install pixi --save

  2. 进口

    import {PIXI} from 'pixi';

  3. 正在使用

    var stage = new PIXI.Stage(0x66FF99);

错误:TypeError: Cannot read property 'Stage' of undefined

请帮助我。

tutorial on Include External JavaScript Libraries In An Angular 2 TypeScript Project 最终由 Nic Raboy 解决了这个问题。

It says to include the script in the html header as usual web applications, then in the ts file where we need the variable declare it as follow,

declare var libraryVar: any; Then use this libraryVar where ever we need.