How to add a component to a template dynamically?

Hi,

I have a Parent Component (PC) that has a list of items.

I have created a Child Component (CC) that can be added inside the div of one or more of these items.

The problem is I do not know beforehand which items will need a CC. This is to be decided at runtime based on the actions a user takes.

I couldn’t find any resources on injecting a new component in the DOM based on user actions.

Could someone point me in the right direction? Thank you very much.

Hey @crossvalidator , I think this could help you : https://css-tricks.com/creating-vue-js-component-instances-programmatically/

1 Like

Thank you Bruce.

I solved it by following steps in this link

<component :is='variableHoldingComponentSetAccordingToUserInput' />