在Fabricjs上的类型ILineOptions中不存在类

我正在尝试在TypeScrip上实现此答案,https://stackoverflow.com/a/47570603/8503317在Create Line上有此选项

var line = new fabric.Line(points, {
  strokeWidth: 2,
  fill: '#999999',
  stroke: '#999999',
  originX: 'center',
  originY: 'center',
  selectable: false,
  hasBorders: false,
  hasControls: false,
  evented: false,
  class:'line', //THIS DOESN'T EXIST ON FABRIC.LINE OPTIONS

这里是codepen

但在该代码上,它工作正常,没有任何错误。有人知道为什么吗?

编辑

这是我的复制品https://stackblitz.com/edit/angular-ivy-bkaelf?file=src%2Fapp%2Fapp.component.ts


解决方案

由于我没有任何解决方案,我通过手动将class属性添加到ILineOptions@types/fabric来修复它。它现在起作用了,但不是最好的解决方案。如果您找到了最佳答案,请发布新答案

相关文章