角4+的拉斐尔

问题描述 投票:0回答:1

我正在尝试将Raphael添加到Angular 4+项目中。我不知道从哪里开始。理想情况下,我希望它添加类型和全部。我查看了this,但未能使其正常工作。

使用角度式CLI的逐步指南非常棒!

angular typescript raphael
1个回答
0
投票

逐步指南,使用Angular + Raphael设置类型的示例项目。

  1. 使用角度CLI ng new raphael-sampel创建角度项目
  2. 在项目npm install raphael中安装Raphael
  3. 安装Raphael类型npm install --save @types/raphael
  4. <div id="paper"></div>替换app.component.html中的HTML内容>
  5. 将Raphael导入app.component.ts import * as Raphael from 'raphael';
  6. 在app.component.ts中实现OnInit(请参见下文)

  7. import { Component, OnInit } from '@angular/core'; import * as Raphael from 'raphael';

    @@@@ {选择器:“ app-root”,templateUrl:“ ./ app.component.html”,styleUrls:['./ app.component.css']})导出类AppComponent实现OnInit{ngOnInit():无效{let paper = Raphael(document.getElementById('paper'),500,500);paper.circle(100,100,100).attr({'fill':'270-#FAE56B:0-#E56B6B:100'});}}

© www.soinside.com 2019 - 2024. All rights reserved.