相关疑难解决方法(0)

如何在 vue 3 脚本设置中的组件上使用 v-model

我想v-model在组件上添加 a 但收到此警告:

[Vue warn]: Component emitted event "input" but it is neither declared in the emits option nor as an "onInput" prop.
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

[Vue warn]: Component emitted event "input" but it is neither declared in the emits option nor as an "onInput" prop.
Run Code Online (Sandbox Code Playgroud)
// Parent.vue
<template>
  <h2>V-Model Parent</h2>
  <Child v-model="name" label="Name" />
  <p>{{ name }}</p>
</template>

<script setup>
import { ref } from 'vue'
import Child from './Child.vue'

const name = ref('')
</script>
Run Code Online (Sandbox Code Playgroud)

我试图重现本教程,但我被困住了,不知道我错过了什么。

{{ …

vue.js v-model vuejs3 vue-composition-api vue-script-setup

25
推荐指数
2
解决办法
4万
查看次数