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

api(built-in-directives): enhance-v-on-description #2873

Closed
wants to merge 1 commit into from

Conversation

quiteeasy
Copy link

docs: Explain $event behavior with inline handlers

  • Add a description of how the $event object is automatically set when using inline event handlers with v-on
  • Clarify the need to explicitly pass $event when emitting events from child components to preserve the original event data
  • Provide examples to illustrate the correct usage of $event in these scenarios

Related issue: vuejs/core#10945

Copy link

netlify bot commented May 14, 2024

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit d78c378
🔍 Latest deploy log https://app.netlify.com/sites/vuejs/deploys/66437c3276326400082be915
😎 Deploy Preview https://deploy-preview-2873--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -198,6 +198,10 @@ Attach an event listener to the element.

When listening to native DOM events, the method receives the native event as the only argument. If using inline statement, the statement has access to the special `$event` property: `v-on:click="handle('ok', $event)"`.

When using an inline statement with the `$event` property, such as `v-on:click="handle('ok', $event)"`, the inline statement is transformed to `$event => handle('ok', $event)`. This means that the `$event` object is automatically passed as the first argument to the inline function.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're trying to follow show, not tell principle in the docs, and the example below shows the behaviour you're explaining here:

 <button v-on:click="doThat('hello', $event)"></button>

I am not sure any additional clarification is needed here

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

Successfully merging this pull request may close these issues.

None yet

2 participants