PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 13, 2022

[FIXED] How to replace this.$parent.$emit in Vue 3?

 April 13, 2022     javascript, linter, migration, vue.js, vuejs3     No comments   

Issue

I have migrated my application to Vue 3.

Now my linter shows a deprecation error, documented here: https://eslint.vuejs.org/rules/no-deprecated-events-api.html.

The documentation shows how to replace this.$emit with the mitt library, but it doesn't show how to replace this.$parent.$emit.


Solution

In your child component:

setup(props, { emit }) {
   ...
   emit('yourEvent', yourDataIfYouHaveAny);
}

Your parent component:

<your-child @yourEvent="onYourEvent" />

...

onYourEvent(yourDataIfYouHaveAny) {
  ...
}


Answered By - Developer
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing