Index.vue:

<script setup>
import { ref, onMounted } from 'vue'
import Child from './Child.vue'
import './index.css'

const value = ref('')

onMounted(() => {})
</script>

<template>
  <div class="m-home-wrap">
    <div>{{ value }}</div>
    <Child v-model="value"></Child>
    <div class="m-home-demo"></div>
  </div>
</template>

<style></style>

Child.vue:

<template>
  <input v-model="value" placeholder="请输入"/>
</template>
 
<script setup>
const value = defineModel()
</script>
 
<style></style>

vue3在子组件上使用v-model_人工智能