mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
27 lines
622 B
JavaScript
27 lines
622 B
JavaScript
|
|
// In this example, we show how components can be defined and created.
|
||
|
|
import { Component, useState, mount } from "@odoo/owl";
|
||
|
|
|
||
|
|
class Greeter extends Component {
|
||
|
|
static template = "Greeter";
|
||
|
|
|
||
|
|
setup() {
|
||
|
|
this.state = useState({ word: 'Hello' });
|
||
|
|
}
|
||
|
|
|
||
|
|
toggle() {
|
||
|
|
this.state.word = this.state.word === 'Hi' ? 'Hello' : 'Hi';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Main root component
|
||
|
|
class Root extends Component {
|
||
|
|
static components = { Greeter };
|
||
|
|
static template = "Root"
|
||
|
|
|
||
|
|
setup() {
|
||
|
|
this.state = useState({ name: 'World'});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
mount(Root, document.body, { templates: TEMPLATES, dev: true });
|