vuejs / rfcs

RFCs for substantial changes / feature additions to Vue core
4.85k stars 551 forks source link

How the parent component calls the child component method? #269

Closed ZeronoFreya closed 3 years ago

ZeronoFreya commented 3 years ago
// father
<template>
  <children ref="childRef"/>
</template>

<script setup>
import { onMounted } from "vue";
import children from "./children"
ref: childRef = null
onMounted(()=>{
  console.log(childRef);       //  output:  {}
})
</script>

//  children
<template>
  <div>div</div>
</template>

<script setup>
const demo = () => {
  console.log("demo");
}
</script>

How to call the demo method ?

posva commented 3 years ago

Please use our discord server for questions