-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
78 lines (75 loc) · 1.96 KB
/
index.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue.js Modal Example</title>
<script src="../../dist/vue.js"></script>
<link rel="stylesheet" href="modal.css">
</head>
<body>
<!-- template for the modal component -->
<script type="x/template" id="modal-template">
<div class="modal-mask" v-show="show" v-transition="modal">
<div class="modal-wrapper">
<div class="modal-container">
<content select=".modal-header">
<div class="modal-header">
default header
</div>
</content>
<content select=".modal-body">
<div class="modal-body">
default body
</div>
</content>
<content select=".modal-footer">
<div class="modal-footer">
default footer
<button class="modal-default-button"
v-on="click: show = false">
OK
</button>
</div>
</content>
</div>
</div>
</div>
</script>
<script>
// register modal component
Vue.component('modal', {
template: '#modal-template',
props: {
show: {
type: Boolean,
required: true,
twoWay: true
}
}
})
</script>
<!-- app -->
<div id="app">
<button id="show-modal" v-on="click: showModal = true">Show Modal</button>
<!-- use the modal component, pass in the prop -->
<modal show="{{@showModal}}">
<!--
you can use custom content here to overwrite
default content
-->
<div class="modal-header">
<h3>custom header</h3>
</div>
</modal>
</div>
<script>
// start app
new Vue({
el: '#app',
data: {
showModal: false
}
})
</script>
</body>
</html>