逐步指南,使用Angular + Raphael设置类型的示例项目。
ng new raphael-sampel
创建角度项目npm install raphael
中安装Raphaelnpm install --save @types/raphael
<div id="paper"></div>
替换app.component.html中的HTML内容>import * as Raphael from 'raphael';
在app.component.ts中实现OnInit(请参见下文)
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'});}}