如何在打字稿中创建fabric.util.createClass(fabric.Rect)? js上有一个代码。我需要一个关于打字稿的课程。
JS :
Grid = fabric.util.createClass(fabric.Rect, {
initialize: function (theParams) {
this.type = "Grid";
theParams = theParams || {};
this.callSuper('initialize', theParams);
this.top = theParams.top || 40 ;
this.left = 0;
this.offsetX = 0;
}
});
我正在撰写打字稿:
/// <reference types="fabric" />
declare const fabric: any;
export class Grid extends fabric.Rect {
constructor(theParams?: any) {
theParams = theParams || {};
const options: fabric.IRectOptions = {
type: 'Grid',
top = theParams.top || 40 ;,
left: 0
};
super(options);
this.offsetX = 0;
}
错误:
错误TS2346:呼叫目标不包含任何签名。