Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question