-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.vugu
63 lines (54 loc) · 1.06 KB
/
root.vugu
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<div class="root">
<div class="buttons">
<button @click='data.Add()'>Add</button>
<button @click='data.Remove()'>Remove</button>
</div>
<ul vg-for='_, item := range data.Items'>
<li vg-html="item"></li>
</ul>
</div>
<script type="application/x-go">
type RootData struct {
Items []string
}
func (data *RootData) Add() {
items := data.Items[:]
items = append(items, "item")
updateItems(data, items)
}
func (data *RootData) Remove() {
items := data.Items[:]
items = items[:len(items)-1]
updateItems(data, items)
}
func updateItems(data *RootData, items []string) {
res := make([]string, len(items))
copy(res, items)
data.Items = res
}
</script>
<style>
* {
margin: 0;
padding: 0;
}
.root {
align-items: center;
display: flex;
height: 100vh;
flex-direction: column;
justify-content: center;
width: 100vw;
}
.buttons {
flex-direction: row;
}
.buttons button {
font-size: 2rem;
padding: 1rem 2rem;
}
li {
color: #7c5a9e;
font-size: 2rem;
}
</style>