父
<apple :username="username" @closez="close" v-model:key="key"></apple>
let username =ref('张三')
const key = ref('123456')
const close = (e)=>{
console.log("子传递",e);
}
子
<template>
<input v-model="username"/>
<button @click="handleData">发送数据</button>
</template>
<script lang="ts" setup>
import { ref} from "vue";
import { string } from "vue-types";
let username = ref('')
let pwd = ref('')
const props = defineProps({
username:{
type:string,
default:''
}
})
const emit = defineEmits(['closez','update:key'])
const handleData = ()=>{
pwd.value = "123456";
emit('closez',pwd.value)
emit('update:key','14')
}
console.log("父数据",props.username);
</script>
版权声明:本文为qq_42980244原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。