File size: 746 Bytes
4d70170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
<script>
import EventChild from './EventChild.vue'
import EventChild1 from './EventChild1.vue'
import EventChildCond from './EventChildCond.vue'

export default {
  components: {
    EventChild,
    EventChild1,
    EventChildCond,
  },
  data() {
    return {
      toggleCond: false,
    }
  },
  methods: {
    log(data) {
      // console.log('Event fired from child component with data', data)
    },
  },
}
</script>

<template>
  <div>
    <h1>Events</h1>
    <EventChild
      @event="log"
      @event-1="log"
      @event-2="log"
    />
    <EventChild1 @log="log" />
    <EventChildCond
      v-if="toggleCond"
      @log="log"
    />
    <button @click="toggleCond = !toggleCond">
      Toggle Cond
    </button>
  </div>
</template>