core
core copied to clipboard
Multiple roots with v-model giving warnings
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
You should add emits option to opt out of attribute fallthrough for event listeners.
export default {
emits: ['update:modelValue'],
...
}