4👍
✅
In GrandChild.vue
, you’re destructuring the inject
-ed value for an items
property, but the provide
-ed item is an Array
, which has no such property.
Solution
Don’t destructure the inject
-ed value:
// GrandChild.vue
export default {
setup() {
// const { items } = inject('navigation') ❌
const items = inject('navigation') ✅
⋮
},
}
Or provide
the array data in an object with an items
property:
// Parent.vue
export default {
setup() {
// provide('navigation', arrayItems) ❌
provide('navigation', { items: arrayItems }) ✅
⋮
}
}
Source:stackexchange.com