0👍
I tried your code and it works correctly. Don’t know why you come to this problem.
Maybe you want to refactor some details in your code like this:
- testbutton.vue
<template>
<button @click="activate()">Activate</button>
</template>
<script>
export default {
props: ["name"],
methods: {
activate() {
this.$emit("my-name", this.name);
}
}
};
</script>
- app.vue
<template>
<testbutton @my-name="testF1" name="Ricky" />
<testbutton @my-name="testF2" name="Mechelle" />
</template>
<script>
import testbutton from "@/components/testbutton.vue";
export default {
components: {
testbutton
},
methods: {
testF1: name => {
alert(name);
},
testF2: name => {
alert(name);
}
}
};
</script>
Source:stackexchange.com