mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] update example to owl 2 and mount it in the page
This commit is contained in:
committed by
Géry Debongnie
parent
60b01afee3
commit
d7552f1900
+30
-7
@@ -10,6 +10,7 @@
|
|||||||
<link rel="stylesheet" href="assets/milligram.css">
|
<link rel="stylesheet" href="assets/milligram.css">
|
||||||
<link rel="stylesheet" href="assets/highlight.tomorrow.css">
|
<link rel="stylesheet" href="assets/highlight.tomorrow.css">
|
||||||
<link rel="stylesheet" href="assets/main.css">
|
<link rel="stylesheet" href="assets/main.css">
|
||||||
|
<script src="./owl.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header class="container">
|
<header class="container">
|
||||||
@@ -53,25 +54,47 @@
|
|||||||
<h2>Example</h2>
|
<h2>Example</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<section class="column">
|
<section class="column">
|
||||||
<pre><code class="javascript">import { Component, QWeb, useState } from "owl";
|
<pre><code class="javascript">import { mount, Component, useState } from "owl";
|
||||||
|
|
||||||
class Counter extends Component {
|
class Counter extends Component {
|
||||||
state = useState({ value: 0 });
|
setup() {
|
||||||
|
this.state = useState({ value: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
increment() {
|
increment() {
|
||||||
this.state.value++;
|
this.state.value++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const counter = new Counter();
|
mount(Counter, document.body);</code></pre>
|
||||||
counter.mount(document.body);</code></pre>
|
|
||||||
</section>
|
</section>
|
||||||
<section class="column">
|
<section class="column">
|
||||||
<pre><code class="xml"><templates>
|
<pre><code class="xml"><templates>
|
||||||
<button t-name="Counter" t-on-click="increment">
|
<t t-name="Counter">
|
||||||
Click Me! [<t t-esc="state.value"/>]
|
<button t-on-click="increment">
|
||||||
</button>
|
Click Me! [<t t-esc="state.value"/>]
|
||||||
|
</button>
|
||||||
|
</t>
|
||||||
</templates></code></pre>
|
</templates></code></pre>
|
||||||
|
<div id="app-container"></div>
|
||||||
|
<script>
|
||||||
|
const { mount, Component, useState, xml } = owl;
|
||||||
|
|
||||||
|
class Counter extends Component {
|
||||||
|
setup() {
|
||||||
|
this.state = useState({ value: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
|
increment() {
|
||||||
|
this.state.value++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Counter.template = xml`<button t-on-click="increment">
|
||||||
|
Click Me! [<t t-esc="state.value"/>]
|
||||||
|
</button>`;
|
||||||
|
|
||||||
|
mount(Counter, document.getElementById("app-container"));
|
||||||
|
</script>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user