티스토리 뷰
참고링크 | https://kr.vuejs.org/v2/examples/modal.html |
1. Modal.vue파일 생성
(components/common폴더 생성 후 Modal.vue파일 생성함)
- template 내용 / style 내용 붙여 넣기
<template> <transition name="modal"> <div class="modal-mask"> <div class="modal-wrapper"> <div class="modal-container"> <div class="modal-header"> <slot name="header"> 모달 상단 </slot> </div> <div class="modal-body"> <slot name="body"> 모달 내용 </slot> </div> <div class="modal-footer"> <slot name="footer"> 모달 하단 <button class="modal-default-button" @click="$emit('close')"> 닫기 </button> </slot> </div> </div> </div> </div> </transition> </template> <script> export default { } </script> <style> .modal-mask { position: fixed; z-index: 9998; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, .5); display: table; transition: opacity .3s ease; } .modal-wrapper { display: table-cell; vertical-align: middle; color:#555555; } .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, .33); transition: all .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> |
2. 모달을 불러올 페이지에 모달 소스 넣기
template | <button id="show-modal" @click="showModal = true">Show Modal</button> <!-- use the modal component, pass in the prop --> <Modal v-if="showModal" @close="showModal = false"> <!-- you can use custom content here to overwrite default content --> <h3 slot="header">모달 창 제목</h3> </Modal> |
script | <script> import Modal from '../components/common/Modal.vue' export default { data() { return{ showModal: false } }, components : { Modal } } </script> |
vue3버전 --- v-slot : header 로 작업
'WEB > vue.js' 카테고리의 다른 글
[vue.js] fortawesome 사용하기 (0) | 2021.12.21 |
---|---|
ESLint 에러 화면에 표시되지 않게 작업하기 (0) | 2021.11.29 |
vue.js 구구단 (0) | 2021.11.04 |
vue 기본문법 (0) | 2021.11.04 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 무료폰트 #무료웹폰트 #한수원한돋움 #한수원한울림 #한울림체 #한돋움체
- jdk #jre
- 정보처리기사 #정보처리기사요약 #정보처리기사요점정리
- echart
- css미디어쿼리 #미디어쿼리 #mediaquery
- 썬크림 #닥터지썬크림 #내돈내산 #내돈내산썬크림 #썬크림추천 #spf50썬크림 #닥터지메디유브이울트라선
- 테스크탑무선랜카드 #무선랜카드 #아이피타이무선랜카드 #a3000mini #무선랜카드추천
- 연명의료결정제도 #사전연명의료의향서 #사전연명의료의향서등록기관 #광주사전연명의료의향서
- 좋은책 #밥프록터 #부의원리
- 자바스크립트정규표현식
- lg그램pro #lg그램 #노트북 #노트북추천 #lg노트북
- 증폭기 #아이피타임증폭기
- ajax
- 파비콘사이즈
- 자바스크립트countiue
- thymeleaf
- 바지락칼국수 #월곡동칼국수 #칼국수맛집
- 광주분식 #광주분식맛집 #상추튀김 #상추튀김맛집 #광주상추튀김
- 파비콘 #파비콘 사이트에 적용
- SQL명령어 #SQL
- 와이파이약할때
- iptime와이파이증폭기 #와이파이증폭기설치
- 자바스크립트break
- jQuery #jQuery이미지슬라이드 #이미지슬라이드
- 와이파이신호 #와이파이 #와이파이신호세게
- 와이파이증폭기추천 #와이파이설치
- 쇼팬하우어 #좋은책
- 자바스크립트 #javascript #math
- sw기술자평균임금 #2025년 sw기술자 평균임금
- 좋은책
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함