Within my router.ts
, I included some meta properties with a 'getter' that I plan to utilize when the component is loaded.
{
path: "attachments",
name: "AdminJobsAttachments",
meta: {
navbarName: "Attachments",
getter: "Jobs/getJob", // <- this
},
component: () =>
import("@/views/common/Attachments.vue"),
},
To access this information when the component loads, I do the following:
<script lang="ts">
import { defineComponent, ref, computed } from "vue";
import { useRoute } from "vue-router";
import { useStore } from "vuex";
export default defineComponent({
setup() {
const route = useRoute();
const store = useStore();
const getter = computed(() => route.meta.getter);
const routeParam = ref(route.params.id);
const model = computed(() =>
store.getters[getter.value](routeParam.value)
);
return {}
}
})
However, I encounter the following error in Typescript:
Type 'unknown' cannot be used as an index type.
Since I am relatively new to Typescript, it's possible I am missing something here. I'm struggling to find a solution to this issue.
Any assistance would be greatly appreciated.