-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Closed
Description
Vue version
3.5, 3.6
Link to minimal reproduction
Steps to reproduce
<script setup>
const props = defineProps(["a"])
const model = defineModel()
</script>
<template>
{{ Object.keys(props) }}
</template>
see minimal reproduction
What is expected?
only prop keys defined by defineProps ("a") will be shown
What is actually happening?
extra prop keys ("modelValue", "modelModifiers") are shown
System Info
Any additional comments?
For actual case, I use defineOptions({ inheritAttrs: false }) and defineProps to separate bindings for wrapper and content components. e.g.
<script setup>
defineOptions({ inheritAttrs: false })
const { prop1, prop2, ...props } = defineProps(["prop1", "prop2", "class", "style"])
const model = defineModel()
</script>
<template>
{{ Object.keys(props) }}
<div v-bind="props">
<my-component v-bind="$attrs"></my-component>
</div>
</template>
I'll have to drop extra model keys ("modelvalue", "modelmodifiers") from the props object, otherwise it will render the wrapper element with extra attributes (<div class="my-class" modelvalue="[object Object]">)
Metadata
Metadata
Assignees
Labels
No labels