I would like to pass provide and inject to a "page-section" component that could contain itself recursively using a slot.
The goal is for each one of these "page-section" components to pass its id concatenated after the rest of the passed down ids (separated by /) to create a path of all the containing components.
Some of the these "page-section" could also contain other types of components.
This is what I was trying unsuccessfully:
Vue.component('text-input', {
props: ['text', 'id'],
template: '<input type="text" :value="text"',
inject: ['sectionPath']
});
Vue.component('page-section', {
props: ['id'],
template: '<div><slot></slot></div>',
inject: {
sectionPath: { default: '/' }
},
provide: {
sectionPath: this.sectionPath + '/' + this.id
}
}
});