반응형
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 |
Tags
- vsCode
- node
- 네트워크
- centos
- jest
- unittest
- 맥
- TensorFlow
- webpack
- ReactNative
- xcode
- Chrome
- build
- PYTHON
- androidstudio
- 리눅스
- MachineLearning
- IOS
- 개발
- 티스토리챌린지
- react
- Android
- 센토스
- localserver
- 오블완
- VirtualBox
- qunit
- linux
- MAC
Archives
- Today
- Total
로메오의 블로그
[VUE + TYPESCRIPT] Emit 이벤트, 부모에게 이벤트 전달 본문
반응형
src/component/Home.vue
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<child @counter="counter"></child>
<p>자식에게 받은 counter: {{ count }}</p>
</div>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import Child from '@/components/Child.vue';
@Component({
components: {
Child,
},
})
export default class Home extends Vue {
count: number = 0;
counter() {
this.count++;
}
}
</script>
src/component/Child.vue
<template>
<div>
<button @click="counter">숫자 올리기</button>
</div>
</template>
<script lang="ts">
import { Component, Vue, Emit} from 'vue-property-decorator';
@Component
export default class Child extends Vue {
@Emit()
counter() {
}
}
</script>
반응형
'Frontend > Vue' 카테고리의 다른 글
[VUE + TYPESCRIPT] @Model (0) | 2021.02.12 |
---|---|
[VUE + TYPESCRIPT] @Provide / @Inject로 데이터 전달 (0) | 2021.02.11 |
[VUE + TYPESCRIPT] Watch 데이터 감시하기 (0) | 2021.02.10 |
[VUE + TYPESCRIPT] Prop 자식에게 데이터 전달하기 (0) | 2021.02.10 |
[Vue + typescript] Component 생성하기 (0) | 2021.02.10 |
Comments