Javascript 在Js中绘制画布不起作用,但在控制台中没有任何错误

Javascript 在Js中绘制画布不起作用,但在控制台中没有任何错误,javascript,oop,canvas,drawing,Javascript,Oop,Canvas,Drawing,我试图用面向对象的Js制作一个绘图画布,我有一些错误,我已经修复了,但是我的代码似乎没有一部分是有效的(甚至没有大小调整)。这是我的js代码。 (我可以提供html,但我只有一个canvas元素和clean按钮) “但控制台中没有任何错误”-this.canvas.width.bind(this)肯定会抛出错误。const signature1=new signature()@晦涩我该在哪里称呼它?在构造函数中?编辑:我在构造函数下调用了,但在控制台中它说有一个意外的标记“;”是的,要么在那里(

我试图用面向对象的Js制作一个绘图画布,我有一些错误,我已经修复了,但是我的代码似乎没有一部分是有效的(甚至没有大小调整)。这是我的js代码。 (我可以提供html,但我只有一个canvas元素和clean按钮)


“但控制台中没有任何错误”-
this.canvas.width.bind(this)
肯定会抛出错误。
const signature1=new signature()@晦涩我该在哪里称呼它?在构造函数中?编辑:我在构造函数下调用了,但在控制台中它说有一个意外的标记“;”是的,要么在那里(
this.start();
),要么只添加
signature1.start()
const signature1=新签名()之后
class signature{
    constructor(){
        this.canvas  = document.querySelector('canvas');
        this.bouton = document.querySelector('button');
        this.ctx = this.canvas.getContext('2d');
        this.dessin = false;
    }

    //sizing  
    tailleCanvas(){
        this.canvas.width= 200;
        this.canvas.height= 200;
    }

    //start the drawing
    start (e){
        this.canvas.addEventListener('mousedown', ()=>{
            this.dessin = true;
            draw(e);
        });
    };

    //draw
    draw({clientX:x, clientY:y}){
        this.canvas.addEventListener('mousemove', ()=>{
            if (!this.dessin) return;

            this.ctx.lineWidth = 3;
            this.ctx.lineCap = 'round';
            this.ctx.strokeStyle = '#171717';

            this.ctx.lineTo(x, y);
            this.ctx.stroke();
            //rendre les lignes moins pixelisé
            this.ctx.beginPath();
            this.ctx.moveTo(x,y);
        })
    };

    //stop drawing
    stop(){
        this.canvas.addEventListener('mouseup', ()=>{
            this.dessin = false;
            this.ctx.beginPath();
        });
    };

    //clean canvas
    bouttonSup(){
        this.bouton.addEventListener('click', ()=>{
        this.ctx.clearRect(0,0,this.canvas.width, this.canvas.height);
        })
    }
};
const signature1 = new signature();