-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path15. slots.html
63 lines (46 loc) · 1.4 KB
/
15. slots.html
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
<!DOCTYPE html>
<html>
<head>
<title>Slots</title>
<script type="text/javascript" src="https://vuejs.org/js/vue.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<style type="text/css">body { color: #fff; }</style>
</head>
<body>
<div id="my-app" class="d-flex flex-row p-4">
<sl0ts>
<span>Active Page</span>
<ul slot="items">
<li><a href="">Category X</a></li>
<li><a href="">Category Y</a></li>
<li><a href="">Category Z</a></li>
</ul>
</sl0ts>
</div>
<script type="text/javascript">
Vue.component('sl0ts', {
template: `<div class="p-2 dropdown" :class="{show : show}">
<button @click="toggle" class="btn btn-primary">
<slot>Unknown Item</slot>
</button>
<div class="dropdown-menu" v-if="show">
<slot name="items"></slot>
</div>
</div>`,
data() {
return {
show: false,
}
},
methods: {
toggle() {
this.show = !this.show;
}
}
})
new Vue({
el: '#my-app',
})
</script>
</body>
</html>