반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- localserver
- VirtualBox
- linux
- Android
- vsCode
- 리눅스
- 개발
- TensorFlow
- pydantic
- 티스토리챌린지
- PYTHON
- 네트워크
- 맥
- webpack
- fastapi
- 센토스
- react
- IOS
- centos
- node
- unittest
- ReactNative
- xcode
- Chrome
- MAC
- 오블완
- build
- MachineLearning
- androidstudio
Archives
- Today
- Total
로메오의 블로그
[Vue3 + typescript] provide, inject 본문
반응형
VUE.JS 목록
부모, 자식 콤포넌트간 데이터 공유를 위하여 사용함
parentComponent.vue
<template>
<div>
<ChildComponent />
</div>
</template>
<script lang="ts">
import { defineComponent, ref, provide } from 'vue'
import ChildComponent from './ChildComponent.vue'
export default defineComponent({
name: 'ParentComponent',
components: { ChildComponent },
setup () {
const text = ref('hello')
// provide 등록
provide('text', text)
return { text }
}
})
</script>
childComponent.vue
<template>
<div>{{ text }}</div>
</template>
<script lang="ts">
import { defineComponent, inject } from 'vue'
export default defineComponent({
name: 'ChildComponent',
setup () {
// inject로 데이터 추출
const text = inject('text')
return { text }
}
})
</script>
VUE.JS 목록
반응형
'Frontend > Vue' 카테고리의 다른 글
| [Vue3 + typescript] pinia (0) | 2022.09.13 |
|---|---|
| [Vue3 + typescript] Quasar 스타일 (0) | 2022.09.08 |
| [Vue3 + typescript] Quasar 설치 [quasar-cli] (0) | 2022.09.06 |
| [Vue3 + typescript] Quasar 설치 [vite-plugin] (0) | 2022.09.06 |
| [Vue3 + typescript] reactive, ref, toRefs 반응성 주입 (0) | 2022.09.06 |
Comments