父组件给子组件传参
父组件
import Children from "./components/Children.vue";
import {ref} from "vue"
<Children :data="data" />
let data = ref("666")
子组件
const props = defineProps({
data: {
default: "",
type: String
}
})
子组件调用父组件函数
子组件
const emit = defineEmits(['fatherFun'])
调用
emit('fatherFun', '参数')
父组件
<Components @fatherFun="fatherFun" />
function fatherFun(options){
console.log(options)
}