T
T
testtoster2020-03-25 07:43:21
JavaScript
testtoster, 2020-03-25 07:43:21

What is the problem with canvas output?

Created a div tag in html. launched canvas output into it. Got [object Object]. Where did I go wrong?

Also in div width="undefined" and height are also undefined.

Help to understand the error.

class Draw {
    constructor(h, w, id) {
        this.h = h;
        this.w = w;

    }
    create() {
        let createConvas = document.querySelector('div');
        createConvas.innerHTML = `<convas width=${this.w} height=${this.h}></convas>`;

        return createConvas;

    }
}

let draw = new Drawd;
draw.create(2, 4);

document.body.append(draw)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tigran Abrahamyan, 2020-03-25
@testtoster

class Draw {
    constructor(h, w, id = '') {
        this.h = h;
        this.w = w;
    }

    create() {
        let createConvas = document.querySelector('div');
        createConvas.innerHTML = `<canvas width=${this.w} height=${this.h}></canvas>`;

        return createConvas;
    }
}

let draw = new Draw(2, 4);
draw.create();

document.body.append(draw);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question