I have a component called CanvasComp which I am importing from my components folder. I am rendering this component on my template like <CanvasComp :jsoData="data"/>
. It is sending the jsonData to the component. What I want is to render this component dynamically without having to display it manually on the template then pass the jsonData dynamically also.Below is my current implementation:
<template>
<ion-page id="main-content">
<CanvasComp :jsoData="data"/>
</ion-page>
</template>
<script lang="ts">
import { defineComponent, onBeforeMount, onMounted, ref, watch, watchEffect, reactive, computed } from "vue";
import { IonContent,IonPage } from "@ionic/vue";
import CanvasComp from "@/components/CanvasComp.vue";
export default defineComponent({
name: "GraphView",
components: {
IonContent,
IonPage,
CanvasComp,
},
setup() {
const data= [
{ id: 1, name: 'Default' },
{ id: 2, name: 'Demographics'},
{ id: 3, name: 'Other'},
];
}
return { data, CanvasComp }
</script>
Is there a way I can render that <CanvasComp :jsoData="data"/>
in my template dynamically while passing the jsonData as well?
e.g const CanvasComp = prop{jsonData: data};
then return it.