-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
Copy pathEventChild.vue
76 lines (71 loc) · 1.35 KB
/
EventChild.vue
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<script>
export default {
methods: {
emitEvent() {
const data = {
eventName: 'event',
}
this.$emit('event', data)
},
emitEvent1() {
const data = {
eventName: 'event-1',
}
this.$emit('event-1', data)
},
emitEvent2() {
const complexData = {
componentName: 'EventChild',
string: 'Lorem ipsum',
complex: {
string: 'Lorem ipsum',
object: {
number: 23,
boolean: true,
array: [1, 2, 3, 4, 5],
},
},
}
this.$emit('event-2', complexData)
},
emitManyEvents() {
for (let i = 0; i < 10000; i++) {
this.$emit('event', i)
}
},
emitAndCommit() {
this.$emit('event-1', 'foobar')
this.$store.commit('DECREMENT', 'barfoo')
},
},
}
</script>
<template>
<div>
<button
class="btn-emit-event"
@click="emitEvent"
>
Emit
</button>
<button
class="btn-emit-event1"
@click="emitEvent1"
>
Emit
</button>
<button
class="btn-emit-event2"
@click="emitEvent2"
>
Emit
</button>
<br>
<button @click="emitManyEvents">
Emit a lot of events
</button>
<button @click="emitAndCommit">
Emit and event and commit a mutation
</button>
</div>
</template>