Hi Ghazal Nikmanesh,
Thank you for your patience. We would like to inform you that the provide()
function accepts the first argument as the injection key, which can be a
string or a symbol. The second argument is the provided value.
Additionally, we need to provide the injection key in the inject() function.
Please find the corrected code snippet below for
your reference:
|
parent component:
<script setup lang="ts">
import { provide } from 'vue'
const nums = [1, 2]
provide('numbers', nums)
</script>
child component:
<script setup lang="ts">
const numbers = inject('numbers')
console.log(numbers)
</script>
|
Kindly find the below links for your reference.
https://vuejs.org/guide/components/provide-inject.html#provide
https://vuejs.org/guide/components/provide-inject.html#inject
If you require any further
assistance or have additional questions, please feel free to let us know.
Regards,
Deepika.