Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit issue on Vue 3. #196

Open
tejas208 opened this issue Apr 9, 2024 · 1 comment
Open

Emit issue on Vue 3. #196

tejas208 opened this issue Apr 9, 2024 · 1 comment

Comments

@tejas208
Copy link

tejas208 commented Apr 9, 2024

Hi,

Here is my app.js code:
import mitt from 'mitt'
const emitter = mitt();

app.config.globalProperties.$bus = emitter;

Here is my ActionButton.vue code

<script> export default { props: ["data", "index",'showDelete'], methods: { getBasicDetails(id) { this.$bus.emit("details", id); }, deleteRecord(id) { this.$swal .fire({ title: "Are you sure?", html: "You want to delete", icon: "warning", showCancelButton: true, confirmButtonColor: "#60217D", cancelButtonColor: "#d33", confirmButtonText: "Yes", }) .then((result) => { if (result.value) { this.$bus.emit("delete", id); } }); }, }, }; </script> When we click on the edit button that time this.$bus.emit() event is not fire. can you please help me for the error occured.

Thanks!

@tejas208 tejas208 closed this as completed Apr 9, 2024
@tejas208 tejas208 reopened this Apr 9, 2024
@tejas208 tejas208 closed this as completed Apr 9, 2024
@tejas208 tejas208 reopened this Apr 9, 2024
@daydayup001001
Copy link

You can use emit in the following ways:
File path:“src/utils/bus.js”
...JavaScript
import mitt from 'mitt'
const EventBus = mitt()
export default EventBus
...

Use path :"scr/view/use.vue"
...vue

<script setup> import EventBus from "@/utils/bus"; EventBus.emit(message.name, message); </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants