其他分享
首页 > 其他分享> > vue3.2 v-model

vue3.2 v-model

作者:互联网

注意点:<Children v-model:text='textBoxValue'/> 不能省略v-model,

 <template>
    <h1>Parent</h1>
    <h2>{{textBoxValue}}</h2>
    <Children v-model:text='textBoxValue'/>
</template>

<script setup>
import Children from './Children.vue'

import {ref} from 'vue'

const textBoxValue = ref('空空如也')

</script>

 

<template>
    <input type="text" :value="text" @input="inputEvent" />
</template>

<script setup>

defineProps({
    text: String
})

const emits = defineEmits();

const inputEvent = (e) => {
    console.log(e.target.value);
    emits('update:text', e.target.value)
}
</script>

 

标签:const,text,textBoxValue,vue3.2,import,model,ref,emits
来源: https://www.cnblogs.com/Jiaojiawang/p/15914046.html