$emit() doesn't work
See original GitHub issueclean install and replace with this two components. App.vue ->
<template>
<view class="container">
<text class="text-color-primary">My First Text</text>
<children v-on:custom-event="customEventHandler">
<text class="text-color-primary">My slot</text>
<template slot="namedslot">
<text class="text-color-primary">My slot 2</text>
</template>
</children>
</view>
</template>
<script>
import children from './children.vue'
export default {
components: {
children
},
methods:{
customEventHandler(value){
console.log(value);
}
}
}
</script>
<style>
.container {
background-color: white;
align-items: center;
justify-content: center;
flex: 1;
}
.text-color-primary {
color: blue;
}
</style>
```
new children.vue ->
```
<template>
<view>
<button class="text-color-primary" :on-press="click(1)" title="HELLOW"></button>
<slot></slot>
<button class="text-color-primary" :on-press="click(2)" title="HELLOW2"></button>
<slot name="namedslot"></slot>
</view>
</template>
<script>
export default {
methods: {
click(value){
console.log('childer clicked:'+ value);
this.$emit('custom-event',value);
}
}
}
</script>
<style>
.text-color-primary {
color: green;
}
</style>
```
App vue doesnt receive anything and the view doesnt show as expected
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Why does $emit not work in my vue component - Stack Overflow
emit() is a way to say to the parent component that hey i created an ... you don't listen in parent component the...
Read more >basic $emit() function not working - Laracasts
basic $emit() function not working. Im 2 weeks old when it comes to vue. js im struggling since couple of days ago to...
Read more >$emit not working - Get Help - Vue Forum
$emit is used for child => parent component communication. Dispatching an $emit event won't send it out globally. It will only send the...
Read more >ParticleEmitter:Emit() doesn't work - Scripting Support
I expected a particle to be emitted as soon as the script run, although I got “emitted” printed to the console, but no...
Read more >A Guide to Vue $emit - How to Emit Custom Events in Vue
How does Vue Emit Work? When we emit an event, we invoke a ... We are emitting an event called add and passing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please upvote the issue if you guys want it to be fixed. As of now, It doesn’t seem to be important since there is a workaround for the $emit.
A quick workaround to invoke functions from childs to parents until $emit is fixed. Allows dumb and smart components to function as expected in Vue Native.