일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 데이터시각화
- 샤오미
- 중고노트북
- 인공지능
- 대한민국선거
- 코란도스포츠
- 저출산
- 액티언스포츠
- 도로패임
- MTB
- 가칭 동남고등학교
- 픽업트럭
- 40대아빠육아
- 싸이클
- 청주시 지하철
- 아빠육아
- 파리브레스트파리
- 미지아
- 국민을 위한 국민연금은 없다
- 2024년 합계출산율
- 자전거
- 육아휴직급여
- 콜로라도
- 오프로드
- 감나무전지
- 청주시 일반계 고등학교
- 준연동형비례대표
- 엔진오일
- 남자육아휴직
- 전동전기톱
Archives
- Today
- Total
열심히 일한 당신 떠나라
코딩 자율학습단(Vue.js 프런트엔드 개발 입문) 7일차 본문
5장 컴포넌트 다루기
5.5 컴포넌트의 데이터 효율적으로 다루기
컴포넌트의 데이터 공유하기(provide, inject)
// App.vue
<script>
import FirstChild from './components/FirstChild.vue';
export default {
components: {
FirstChild,
},
provide() {
return {
message: this.message,
};
},
data() {
return {
message: 'Hello, Vue.Js',
};
},
}
</script>
<template>
<FirstChild />
</template>
// FirstChild.vue
<script>
export default {
inject: ['message'],
}
</script>
<template>
<h1>컴포넌트</h1>
<p>내가 만든 첫 번째 컴포넌트</p>
<h1> {{ message }}</h1>
</template>
<style>
h1 {
color: blue;
}
p {
color: green;
}
</style>
컴포넌트의 데이터 참조하기($refs, $parent)
5.6 컴포넌트 슬롯 사용하기
이름이 없는 슬롯
// CustomButton.vue
<template>
<button class="btn">
<slot></slot>
</button>
</template>
//App.vue
<template>
<CustomButton>더블클릭</CustomButton>
</template>
이름이 있는 슬롯
// 형식
<template>
<slot name="값"></slot>
<slot name="header"></slot>
<slot name="main"></slot>
</template>
슬롯에 기본값 적용하기
<template>
<button class="btn">
<slot>제출</slot>
</button>
</template>
'정보교육 > 프런트엔드' 카테고리의 다른 글
코딩 자율학습단(Vue.js 프런트엔드 개발 입문) 9일차 (0) | 2024.06.28 |
---|---|
코딩 자율학습단(Vue.js 프런트엔드 개발 입문) 8일차 (0) | 2024.06.27 |
코딩 자율학습단(Vue.js 프런트엔드 개발 입문) 6일차 (0) | 2024.06.24 |
vue.js 프로젝트: 일정 관리가 포함된 홈페이지 만들기 (0) | 2024.06.23 |
코딩 자율학습단(Vue.js 프런트엔드 개발 입문) 5일차 (0) | 2024.06.22 |