Skip to content
Snippets Groups Projects
Commit c723fecc authored by Thomas Fritsch's avatar Thomas Fritsch
Browse files

B.3.2. Component de base

parent 0da58e1d
No related branches found
No related tags found
No related merge requests found
......@@ -22,13 +22,21 @@ const data = [
}
];
class Animal {
constructor( name ){
this.name = name;
class Component {
tag;
children;
constructor( tag, children ){
this.tag = tag;
this.children = children;
}
fly() { // déclaration de méthode
console.log(`${this.name} is flying !`);
render() {
return `<${this.tag}>
${this.children ? this.children : ''}
</${this.tag}>`;
}
}
const threeEyedRaven = new Animal( 'Bran' );
threeEyedRaven.fly();
\ No newline at end of file
const title = new Component( 'h1', 'La carte' );
document.querySelector('.pageTitle').innerHTML = title.render();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment