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

Multiple roots with v-model giving warnings #1510

Closed
Kurira opened this issue Jul 5, 2020 · 1 comment
Closed

Multiple roots with v-model giving warnings #1510

Kurira opened this issue Jul 5, 2020 · 1 comment

Comments

@Kurira
Copy link

Kurira commented Jul 5, 2020

What problem does this feature solve?

I have a component which looks similar to this

<template>
    <div>{{ modelValue }}</div>
    <div>Some other content</div>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
    props: {
        modelValue: String
    },
    setup() {
        return { };
    }
});
</script>

whenever I use v-model on the component <my-component v-model="value" /> which has multiple roots it always gives warnings

[Vue warn]: Extraneous non-emits event listeners (update:modelValue) were passed to component but could not be
automatically inherited because component renders fragment or text root nodes. If the listener is intended to be
a component custom event listener only, declare it using the "emits" option. 
  at <my-component modelValue=null onUpdate:modelValue=fn > 

can multi roots be supported with v-model without warnings? Or any way to wrap it with non-renderable tag?

What does the proposed API look like?

none

@CyberAP
Copy link
Contributor

CyberAP commented Jul 6, 2020

You should add emits option to opt out of attribute fallthrough for event listeners.

export default {
  emits: ['update:modelValue'],
  ...
}

@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants