mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[DOC] readme: improve main example
This commit is contained in:
@@ -23,6 +23,10 @@ Here is a short example to illustrate interactive components:
|
|||||||
<button t-name="Counter" t-on-click="increment">
|
<button t-name="Counter" t-on-click="increment">
|
||||||
Click Me! [<t t-esc="state.value"/>]
|
Click Me! [<t t-esc="state.value"/>]
|
||||||
</button>
|
</button>
|
||||||
|
<div t-name="App">
|
||||||
|
<span>Hello Owl</span>
|
||||||
|
<Counter />
|
||||||
|
</div>
|
||||||
</templates>
|
</templates>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -35,9 +39,13 @@ class Counter extends owl.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class App extends owl.Component {
|
||||||
|
components = { Counter };
|
||||||
|
}
|
||||||
|
|
||||||
const qweb = new owl.QWeb(TEMPLATES);
|
const qweb = new owl.QWeb(TEMPLATES);
|
||||||
const counter = new Counter({ qweb });
|
const app = new App({ qweb });
|
||||||
counter.mount(document.body);
|
app.mount(document.body);
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that we assume here that the xml templates are available in the `TEMPLATES`
|
Note that we assume here that the xml templates are available in the `TEMPLATES`
|
||||||
@@ -99,4 +107,4 @@ Some npm scripts are available:
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
OWL is [GPL licensed](./LICENSE).
|
OWL is [LGPL licensed](./LICENSE).
|
||||||
|
|||||||
+1
-1
@@ -103,7 +103,7 @@ const actions = {
|
|||||||
try {
|
try {
|
||||||
const loginInfo = await doSomeRPC("/login/", info);
|
const loginInfo = await doSomeRPC("/login/", info);
|
||||||
state.loginState = loginInfo;
|
state.loginState = loginInfo;
|
||||||
} catch {
|
} catch (e) {
|
||||||
state.loginState = "error";
|
state.loginState = "error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user