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
- 칭기즈칸의 위대한 장군 수부타이
- 이펙티브 자바
- 월칙
- ESG
- 공헌감
- Container
- 모두가 기다리는 사람
- 비메모리 자원
- try width resources
- kubernetes
- 쿠버네티스
- 레퍼런스 복사
- node
- 히든 스토리
- 부자의그릇
- HTML
- apache kafka
- 참조 계수
- java
- 과제의 분리
- try-with-resources
- sentry
- 뉴 컨피던스
- 아웃풋법칙
- 수부타이
- docker
- Infresh
- 도파민형 인간
- CSS
- colllection
Archives
- Today
- Total
Hi
$emit 본문
v-on 을 이용한 사용자 지정 이벤트
$on(eventName) 을 사용하여 이벤트를 감지 하십시오. $emit(eventName) 을 사용하여 이벤트를 트리거 하십시오.
<body>
<div id="counter-event-example">
<p>{{ total }}</p>
<button-counter v-on:increment="incrementTotal"></button-counter>
<button-counter v-on:increment="incrementTotal"></button-counter>
</div>
<script type="text/javascript">
Vue.component('button-counter', {
template: '<button v-on:click="incrementCounter">{{ counter }}</button>',
data: function () {
return {
counter: 0
}
},
methods: {
incrementCounter: function () {
this.counter += 1;
this.$emit('increment');
}
}
});
new Vue({
el: '#counter-event-example',
data: {
total: 0
},
methods: {
incrementTotal: function () {
this.total += 1;
}
}
})
</script>
</body>
Vue 객체 안에서
this.$emit('increment');
라고 하면 바깥에서
<button-counter v-on:increment="incrementTotal"></button-counter>
이런 식으로 받아 들일 수 있다.
'WEB(웹) > vuejs' 카테고리의 다른 글
this.$route (0) | 2018.10.13 |
---|---|
boilerplate (0) | 2018.09.27 |
SPA(Single Page Application) (0) | 2018.09.27 |
vue windows 로 변경시 eslint error (0) | 2018.09.06 |
vue setting 하는 법 (0) | 2018.09.06 |