모달 창이 사라지지 않고 처음부터 계속 띄어져있어요
484
임명수
작성한 질문수 1
1
<template>
<div class="inputBox shadow">
<input type="text" v-model="newTodoItem" placeholder="Type what you have to do"
v-on:keyup.enter="addTodo">
<span class="addContainer" v-on:click="addTodo">
<i class="addBtn fa fa-plus" aria-hidden="true"></i>
</span>
<Modal> v-if="showModal" @close="showModal = false">
<h3 slot="header">
경고!
</h3>
</Modal>
</div>
</template>
<script>
import Modal from './common/Modal.vue'
export default{
data: function(){
return {
newTodoItem:'',
showModal: false
}
},
methods: {
addTodo: function(){
if(this.newTodoItem !== ''){
this.$emit('addTodoItem', this.newTodoItem);
this.clearInput();
}else{
this.showModal = !this.showModal;
}
},
clearInput(){
this.newTodoItem = '';
}
},
components:{
Modal: Modal
}
}
</script>위에는 TodoInput.vue 부분입니다.
<template>
<Transition name="modal">
<div class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header">default header</slot>
</div>
<div class="modal-body">
<slot name="body">default body</slot>
</div>
<div class="modal-footer">
<slot name="footer">
default footer
<button
class="modal-default-button"
@click="$emit('close')"
>OK</button>
</slot>
</div>
</div>
</div>
</div>
</Transition>
</template>
<style>
.modal-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: table;
transition: opacity 0.3s ease;
}
.modal-wrapper {
display: table-cell;
vertical-align: middle;
}
.modal-container {
width: 300px;
margin: 0px auto;
padding: 20px 30px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
transition: all 0.3s ease;
}
.modal-header h3 {
margin-top: 0;
color: #42b983;
}
.modal-body {
margin: 20px 0;
}
.modal-default-button {
float: right;
}
/*
* The following styles are auto-applied to elements with
* transition="modal" when their visibility is toggled
* by Vue.js.
*
* You can easily play with the modal transition by editing
* these styles.
*/
.modal-enter-from {
opacity: 0;
}
.modal-leave-to {
opacity: 0;
}
.modal-enter-from .modal-container,
.modal-leave-to .modal-container {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
</style>
위에는 Modal.vue 부분입니다.

위는 프로젝트 구조입니다.
모달창이 저렇게 계속 띄어져있습니다. 그냥 실행하자마자 띄어져있고 OK를 눌러도 닫혀지지가 않습니다. 왜 그런지 혹시 알 수 있을까요?
답변 1
Chrome 개발자 모드 확장이 안됨
0
272
1
깃 권한 요청드립니다
0
118
1
vue.js 중급 리포지토리 권한 관련
0
118
1
vuex + axios 질문 있습니다!
1
198
2
깃 권한 요청드립니다!
0
163
1
강의 깃주소 문의
0
145
1
router-view에 props를 어떻게 넘길 수 있나요?
1
281
2
Vue가 인식되지 않는 현상
0
207
1
기초강좌는 어디있나요?
1
193
2
App.vue가 필요한 이유
0
193
1
getter가 정의되어 있지 않아 오류가 발생합니다.
1
256
1
뷰 라이프사이클
1
188
1
TSLint 말고 TSLint Vue 설치해도 되나요?
1
369
3
로컬 스토리지는 어디에 있나요?
1
282
1
vuex 실행시 새로고침해야지만 리스트에 나타나는 현상
1
391
2
export default 관련한 질문
0
357
2
깃허브 vue-todo 접근불가에 따른 확인요청
1
356
2
깃허브에 문제있는것 같습니다.
1
275
2
인프런 강의 재생 화면 구성 변경 문의드립니다
1
306
2
addTodo Helper 함수 적용
1
244
1
vuex 헬퍼 전역 설정
1
248
2
github 권한요청드립니다.
1
258
2
이벤트 위치에 대한 궁금증 입니다.
1
224
2
구조 차이에 대한 문의
1
347
2






<Modal v-if ~~~> 형태로 작성하셔야 합니다 :)