<div id="content_views" class="markdown_views prism-atom-one-dark">
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
</svg>
<h4><a name="t0"></a><a id="vue3vmodel_0"></a>vue3报错之:使用<code>v-model</code>父子组件传值,子组件修改父组件里面的值的时候,报警告</h4>
warn:Component emitted event “update:dialogAddVisible” but it is neither declared in the emits option nor as an “onUpdate:dialogAddVisible” prop
父组件Father.vue
:
子组件Child.vue
:
报错:
根据字面意思是说,
一个[Vue警告]:组件触发事件"update:dialogVisible",但它既没有在发出选项中声明,也没有在"onUpdate:dialogVisible"中声明道具。
解决办法:我们在使用defineEmits声明的时候,给要传入的值前面加上update
,这样就不会警告了!