-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
47 lines (42 loc) · 936 Bytes
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import html from '../../src/index';
import jiayou from 'url:./jiayou.gif';
const state = {
counter: 0,
};
const setCounter = (val: number) => {
state.counter = val;
render();
};
const containerClassName = 'counter-wrapper';
function render() {
const $app = document.querySelector('#app');
const myComponent = html`
<div class="${containerClassName}" hidden=${false}>
${html` <img src="${jiayou}" alt="woowa-img" /> `}
<div>
<button
class="btn"
onClick=${() => {
setCounter(state.counter - 1);
}}
>
-
</button>
<span>${state.counter}</span>
<button
class="btn"
onClick=${() => {
setCounter(state.counter + 1);
}}
>
+
</button>
</div>
</div>
`;
if ($app) {
$app.innerHTML = '';
$app.appendChild(myComponent);
}
}
render();