Импорт CreateJS в приложение Angular 6 - PullRequest
0 голосов
/ 15 октября 2018

Я пытаюсь использовать CreateJS в своем приложении Angular.Я установил оба пакета: typing и createjs NPM.Я положил /// <reference types="@types/createjs" /> вверху моего файла.Приложение компилируется, но в веб-браузере выдает ошибку:

ОШИБКА ReferenceError: createjs не определен

Как я могу определить 'createjs'?Мой машинописный код ниже.Спасибо.

/// <reference types="@types/createjs" /> 
import { Component, AfterViewInit } from '@angular/core';


@Component({
  selector: 'timeline-creator',
  template: '<canvas width="1000" height="500"id="demoCanvas"></canvas>'
})
export class TimelineCreatorComponent implements AfterViewInit {

 ngAfterViewInit (){


  var stage = new createjs.Stage("demoCanvas")
  var circle = new createjs.Shape();
  circle.graphics.beginFill("DeepSkyBlue").drawCircle(0, 0, 50);
  circle.x = 100;
  circle.y = 100;
  stage.addChild(circle);
  stage.update();

 }
}

1 Ответ

0 голосов
/ 15 октября 2018

Кажется, что @types для createjs отформатированы как пространство имен вместо модуля.Если вы импортируете, как показано ниже:

import 'createjs';

Вы можете получить доступ, например:

createjs.Stage
...