【发布时间】:2019-09-23 14:47:01
【问题描述】:
我正在使用 Angular 7 并且已经能够使用 SVG.js v2.*,但我无法让 SVG.js v3.* 工作。我做了两个 github 项目,第一个显示 SVG.js v2 工作 angular7-svgjs2,第二个显示 SVG.js v3 不能工作,唯一改变的是导入的库 angular7-svgjs3
使用 SVG.js 2.7*(可行)
import { Component, AfterContentInit } from '@angular/core';
import * as SVGjs from 'svg.js';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterContentInit {
title = 'angular7-svgjs2';
ngAfterContentInit () {
let draw = SVGjs('drawing');
let rect = draw.rect(100, 100);
}
}
使用 SVG.js 3.0.*(失败)
import { Component, AfterContentInit } from '@angular/core';
import * as SVGjs from '@svgdotjs/svg.js';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterContentInit {
title = 'angular7-svgjs3';
ngAfterContentInit () {
let draw = SVGjs('drawing');
let rect = draw.rect(100, 100);
}
}
【问题讨论】: