모달창 관련 질문입니다.
474
投稿した質問数 5
- 먼저 유사한 질문이 있었는지 검색해보세요.
- 서로 예의를 지키며 존중하는 문화를 만들어가요.
- 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.
回答 2
0
안녕하세요 beegizee1220님, 궁금하신 부분 잘 해결되어서 다행이네요. 참고로 하위 컴포넌트의 루트 엘리먼트 레벨에 v-if 넣으시는 것보다 외부의 컴포넌트 태그 레벨에서 v-if로 넣어서 제어하는 것이 테스트 코드와 명시적인 코딩 차원에서 더 좋습니다 :)
0
아.. Modal.vue 컴포넌트에 v-if 속성을 주고
TodoInput.vue 컴포넌트에서 v-bind로 props를 내려주는 형태로하면 등장할때도 트랜지션이 잘 적용되네요.
흐음... 강사님 강의에선 왜 된건지 궁금하네요.
버전업되면서 바뀐건지..
여튼 다음과 같이 수정하니까 잘 작동되었습니다!
<template>
<transition name="modal">
<div class="modal-mask" v-if="propsdata">
<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>
</div>
</div>
</transition>
</template>
<script>
export default {
name: "Modal",
props: ['propsdata']
}
</script>
<style scoped>
.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;
font-family: Helvetica, Arial, sans-serif;
}
.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 {
opacity: 0;
}
.modal-leave-active {
opacity: 0;
}
.modal-enter .modal-container,
.modal-leave-active .modal-container {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
</style>
<template>
<div class="inputBox shadow">
<input type="text" v-model="newTodoItem" v-on:keyup.enter="addTodo">
<span class="addContainer" v-on:click="addTodo">
<i class="fas fa-plus addBtn"></i>
</span>
<Modal v-bind:propsdata="showModal">
<h3 slot="header">
경고!
<!-- @는 v-on의 간소화된 문법입니다. short hand -->
<i class="fas fa-times closeModalBtn" @click="showModal=false"></i>
</h3>
<div slot="body">
무언가를 입력하세요.
</div>
</Modal>
</div>
</template>
<script>
import Modal from "@/components/common/Modal";
export default {
name: "TodoInput",
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: function () {
this.newTodoItem = '';
},
},
components: {
Modal,
}
}
</script>
<style scoped>
.input:focus {
outline: none;
}
.inputBox {
background-color: #fff;
height: 50px;
line-height: 50px;
border-radius: 5px;
}
.inputBox input {
border-style: none;
font-size: 0.9rem;
}
.addContainer {
float: right;
display: block;
background: linear-gradient(to right, #6478fb, #8763fb);
width: 3rem;
border-radius: 0 5px 5px 0;
}
.addBtn {
color: #ffffff;
vertical-align: middle;
}
.closeModalBtn {
color: #42b983;
}
</style>
Chrome 개발자 모드 확장이 안됨
0
251
1
깃 권한 요청드립니다
0
118
1
vue.js 중급 리포지토리 권한 관련
0
118
1
vuex + axios 질문 있습니다!
1
198
2
깃 권한 요청드립니다!
0
161
1
강의 깃주소 문의
0
142
1
router-view에 props를 어떻게 넘길 수 있나요?
1
278
2
Vue가 인식되지 않는 현상
0
205
1
기초강좌는 어디있나요?
1
190
2
App.vue가 필요한 이유
0
192
1
getter가 정의되어 있지 않아 오류가 발생합니다.
1
253
1
뷰 라이프사이클
1
187
1
TSLint 말고 TSLint Vue 설치해도 되나요?
1
367
3
로컬 스토리지는 어디에 있나요?
1
279
1
vuex 실행시 새로고침해야지만 리스트에 나타나는 현상
1
387
2
export default 관련한 질문
0
354
2
깃허브 vue-todo 접근불가에 따른 확인요청
1
354
2
깃허브에 문제있는것 같습니다.
1
273
2
인프런 강의 재생 화면 구성 변경 문의드립니다
1
303
2
addTodo Helper 함수 적용
1
242
1
vuex 헬퍼 전역 설정
1
244
2
github 권한요청드립니다.
1
255
2
이벤트 위치에 대한 궁금증 입니다.
1
221
2
구조 차이에 대한 문의
1
343
2

