[Vuejs]-How to call a function from another component in vue3?

-1👍

If you want to conditionally display child component, you can move logic out of that component into the parent component.

Parent.vue

<template>
    <FormComponent v-if="showComponent" />
</template>

Alternatively, you can pass a prop into FormComponent if you need to conditionally display only a part of that component.

Parent.vue

<template>
    <FormComponent v-bind:show-component="showComponent" />
</template>

FormComponent.vue

<template>
    <div v-if="showComponent">
        ...
    </div>
    <div>
        ...
    </div>
</template>

Leave a comment