I would like something similar to this to work:
import { ref, defineComponent, inject } from "vue";
export default defineComponent({
name: "ProgressBar",
setup() {
//this works with hard-coded "StepData", but this.Step_Data is not available here
// const data = inject("StepData") as StepData;
//but if I want to pass the name of the injected data instead I first create a blank data:
const data = ref<StepData>({} as StepData);
return {
data,
};
},
methods: {},
props: {
step_data: {
type: String,
required: true
}
},
And then I try to load it dynamically, but this doesn't work:
mounted() {
this.data = inject(this.step_data) as StepData;
console.log("data:" + JSON.stringify(this.data));
}
The console.log shows the data did get injected, but nothing renders as if it is still empty.