[Vuejs]-Vue3 โ€“ How call function from another component

-3๐Ÿ‘

โœ…

I found solution for my problem: https://pinia.vuejs.org/

Maybe someone will need this info.

Edit

You can use store to manage data across your application

๐Ÿ‘คZaki

1๐Ÿ‘

You probably should use emits to share the data from the child component to the parent. I have set up a Vue3 Composition API example. Check it out here:

Parent:

<template>
<Comp @send-data="callback" />

<input v-model="myInput" />
</template>

<script setup>
import { ref } from 'vue'
import Comp from './Comp.vue'

const myInput = ref('')

const callback = data => myInput.value = data
</script>

Child:

<template>
<button
  @click="btnClicked()"
  v-text="`Click to send data`"
/>
</template>

<script setup>
import { ref } from 'vue'
  
const emits = defineEmits(['sendData'])

const btnClicked = () => emits('sendData', 'some data')
</script>

* If you share some code, we can help you better and write better examples that get near what you want to achieve too.

๐Ÿ‘คericmp

Leave a comment