The Wayback Machine - https://web.archive.org/web/20201123075342/https://github.com/vuejs/composition-api/issues/590
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

SetupContext `attrs` doesn't contain `listeners` #590

Open
Edge00 opened this issue Nov 18, 2020 · 4 comments
Open

SetupContext `attrs` doesn't contain `listeners` #590

Edge00 opened this issue Nov 18, 2020 · 4 comments
Labels

Comments

@Edge00
Copy link

@Edge00 Edge00 commented Nov 18, 2020

According to the document https://vue-composition-api-rfc.netlify.app/api.html#setup

interface Data {
  [key: string]: unknown
}

interface SetupContext {
  attrs: Data
  slots: Slots
  emit: (event: string, ...args: unknown[]) => void
}

function setup(props: Data, context: SetupContext): Data

There is no listeners in SetupContext.
So i use v-bind="attrs" to pass event to component.
But event listeners didn't passed to component.

Will this usage be aligned at vue3 or keep it is now?

@pikax
Copy link
Member

@pikax pikax commented Nov 19, 2020

Can you provide reproduction code and show what you trying to achieve?

@Edge00
Copy link
Author

@Edge00 Edge00 commented Nov 19, 2020

Can you provide reproduction code and show what you trying to achieve?

I'm trying to pass events to component by using v-bind="$attrs" like this:

<template>
  <label>
    <input type="text" v-bind="$attrs" />
  </label>
</template>
<script>
export default {
  inheritAttrs: false
}
</script>

However it doesn't work.
Referance: https://v3.vuejs.org/guide/migration/listeners-removed.html#_3-x-syntax

@antfu
Copy link
Member

@antfu antfu commented Nov 19, 2020

@pikax I think they are taking about this:

<input v-bind="$attrs" v-on="$listeners">

where $listeners get removed in Vue 3

@Edge00 I think this is a misalignment and probably can't be polyfilled by this plugin. You might need to keep using the $ prefixed variables in the templates of Vue 2 at this moment and do the migration when upgrading to Vue 3.

@antfu antfu added the misalignment label Nov 19, 2020
@antfu antfu changed the title attrs doesn't contain events SetupContext `attrs` doesn't contain `listeners` Nov 19, 2020
@Edge00
Copy link
Author

@Edge00 Edge00 commented Nov 19, 2020

@pikax I think they are taking about this:

<input v-bind="$attrs" v-on="$listeners">

where $listeners get removed in Vue 3

@Edge00 I think this is a misalignment and probably can't be polyfilled by this plugin. You might need to keep using the $ prefixed variables in the templates of Vue 2 at this moment and do the migration when upgrading to Vue 3.

Exactly. It would be great if this usage can be aligned at Vue 3.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.