【发布时间】:2021-05-25 16:27:31
【问题描述】:
我是在 Angular 中使用 fabricjs 的新手。我想使用fabric.js 中提供的事件处理功能,使用'on' 方法。但不知何故,它不起作用。有人可以帮忙吗? 我正在使用以下代码:
canvas: fabric.Canvas;
rect: fabric.Rect;
constructor(private zone: NgZone) { }
ngAfterContentInit() {
this.canvas = new fabric.Canvas('canvas', {
backgroundColor: 'lightgrey', width: 400, height: 400
});
this.rect = new fabric.Rect({
width: 100, height: 100, angle: 45, left: 100, top: 100, fill: 'white',
borderColor: 'orange', selectable: true,
})
this.canvas.add(this.rect)
const obj = this.rect.on('mouse:down', (e) => {
console.log('mouse:down', e);
})
}
【问题讨论】: