SOURCE

class ElementStyle{
    width = 0;
    height = 0;
    constructor(style){
        Object.assign(this , style || {})
    }
}

class Element{
    text = '';
    children = [];
    style = new ElementStyle();
    constructor(opts){
        style = new ElementStyle(opts.style);
    }
}

class UIButton extends Element{
    constructor(opts){
        super(opts);
    }
}

var button = new UIButton({
    style: {

    }
});

console.log(button);
* {
  margin: 0px;
}
body{
    padding: 10px;
}
canvas{
    border: 1px solid red;
}
console 命令行工具 X clear

                    
>
console