get warning using @vue/compat
Vue version
3.2.13
Link to minimal reproduction
https://github.com/dxvladislavvolkov/vuevmodel
Steps to reproduce
- Clone repo
- Run npm i
- Run npm run serve
- Open devtools and console tab
- You will see a warning: (deprecation COMPONENT_V_MODEL) Component declares "modelValue" prop, which is Vue 3 usage, but is running under Vue 2 compat v-model behavior. You can opt-in to Vue 3 behavior on a per-component basis with
compatConfig: { COMPONENT_V_MODEL: false }
.
What is expected?
No the warning. Looks like my component is correct.
What is actually happening?
I get the warning.
System Info
No response
Any additional comments?
No response
Your code is correct for Vue 3. But you are running it in Vue 2 compat mode. in Vue 2, v-model requires a value
prop and emits an input
event.
The error message is telling you how to disable Vue 2 compat for v-model as you are already using Vue 3 syntax.
<template>
<div class="content-block">
<input
:value="modelValue"
@input="$emit('update:modelValue', $event.target.value)"
/>
</div>
</template>
<script>
export default {
compatConfig: {
COMPONENT_V_MODEL: false
// or, for full vue 3 compat in this component:
MODE: 3,
},
props: {
modelValue: String
},
emits: ['update:modelValue']
}
</script>
https://v3-migration.vuejs.org/migration-build.html#per-component-config
@LinusBorg But if I use UI library for vue 3 and I don't have the opportunity to set compatConfig inside the component? In this case, how can I fix the warning?
@LinusBorg But if I use UI library for vue 3 and I don't have the opportunity to set compatConfig inside the component? In this case, how can I fix the warning?
Update the library, or switch to something else