21 lines
395 B
JavaScript
21 lines
395 B
JavaScript
export default class Component {
|
|
$target;
|
|
$state;
|
|
constructor ($target) {
|
|
this.$target = $target;
|
|
this.setup();
|
|
this.render();
|
|
}
|
|
setup () {};
|
|
template () { return ''; }
|
|
render () {
|
|
this.$target.innerHTML = this.template();
|
|
this.setEvent();
|
|
}
|
|
setEvent () {}
|
|
setState (newState) {
|
|
this.$state = { ...this.$state, ...newState };
|
|
this.render();
|
|
}
|
|
}
|