vue2/examples/modal/index.html

80 lines
1.9 KiB
HTML
Raw Permalink Normal View History

2015-08-02 04:49:30 +08:00
<!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 -->
2015-08-05 04:32:59 +08:00
<script type="x/template" id="modal-template">
<div class="modal-mask" v-show="show" transition="modal">
2015-08-02 04:49:30 +08:00
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header">
2015-08-02 04:49:30 +08:00
default header
</slot>
</div>
<div class="modal-body">
<slot name="body">
2015-08-02 04:49:30 +08:00
default body
</slot>
</div>
<div class="modal-footer">
<slot name="footer">
2015-08-02 04:49:30 +08:00
default footer
<button class="modal-default-button"
2015-09-16 10:52:55 +08:00
@click="show = false">
2015-08-02 04:49:30 +08:00
OK
</button>
</slot>
</div>
2015-08-02 04:49:30 +08:00
</div>
</div>
</div>
2015-08-05 04:32:59 +08:00
</script>
2015-08-02 04:49:30 +08:00
<script>
// register modal component
Vue.component('modal', {
template: '#modal-template',
props: {
show: {
type: Boolean,
required: true,
twoWay: true
}
}
})
</script>
<!-- app -->
<div id="app">
2015-09-16 10:52:55 +08:00
<button id="show-modal" @click="showModal = true">Show Modal</button>
2015-08-02 04:49:30 +08:00
<!-- use the modal component, pass in the prop -->
2015-09-20 05:02:34 +08:00
<modal :show.sync="showModal">
2015-08-02 04:49:30 +08:00
<!--
you can use custom content here to overwrite
default content
-->
<h3 slot="header">custom header</h3>
2015-08-02 04:49:30 +08:00
</modal>
</div>
<script>
// start app
new Vue({
el: '#app',
data: {
showModal: false
}
})
</script>
</body>
</html>