Vue
HTML
<div id="app">
<div>
<h2>Todos:</h2>
<modal>
<button @click="handleConfirm">예</button>
<button @click="handleCancel">아니오</button>
</modal>
<modal>
<button @click="handleConfirm2">아하</button>
<button @click="handleCancel2">허허허</button>
<button @click="hello">헤헷</button>
</modal>
</div>
</div>
<template id="modal">
<div>
<header>Hello World</header>
<main></main>
<footer>
<slot></slot>
</footer>
</div>
</template>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
Vue
var modal = {
template: '#modal'
}
new Vue({
el: "#app",
components: {
modal
},
methods: {
handleConfirm: function () {
window.alert('예')
},
handleCancel: function () {
window.alert('아니오')
},
handleConfirm2: function () {
window.alert('아하')
},
handleCancel2: function () {
window.alert('허허허')
},
hello: function () {
window.alert('world')
}
}
})