<div>
<!-- 모달맨위에 -->
<div class="black-bg" v-if="state.modal.modal1 == true">
<div class="white-bg">
<h4>상세페이지</h4>
<p>상세페이지내용임</p>
<button v-on:click="state.modal.modal1 = false">close</button>
</div>
</div>
<h1>hello App.vue</h1>
<router-view
@openModal="state.modal.modal1 = true"
:modal="state.modal"
></router-view>
<button v-on:click="test()">axios test</button>
<button type="button" class="btn btn-primary">부트스트랩 테스트</button>
<div class="sassTest">
<p>sassTest_blue</p>
</div>
<button v-on:click="state.modal.modal1 = true">modal1</button>
</div>
이렇게 모달창을 맨위에 올려두고
router로 연결된 컴포넌트에
<template>
<div>
<p>hello Main from router</p>
<button @click="$emit('openModal')">모달1 오픈</button>
</div>
</template>
<script>
export default {
props: {
modal: Object,
},
setup(props) {
console.log(props.modal.modal1);
},
};
</script>
<style></style>
이렇게 emit으로 데이터 보내줌
App.vue에서
<router-view
@openModal1="state.modal.modal1 = true"
:modal="state.modal"
></router-view>
openModal1이라는 데이터를 받으면
모달창을 열게해주는거임.
'javaScript > vueJs' 카테고리의 다른 글
이미지 경로 가져오기 & 이미지 경로 바인딩 & 반복문 (2) | 2023.03.10 |
---|---|
VUE dotenv // vue에서 환경변수 설정 (0) | 2023.01.16 |
vue js // setup()함수안에서 props 데이터 사용하기. (0) | 2022.08.25 |
vue 라우터 메서드안에서 사용하기 (0) | 2022.08.05 |
vue js 기본 // 라우터 기능들. (0) | 2022.07.28 |