[Vuejs]-VueJS – Generating html string of a component in computed property

2👍

Generating HTML in a computed property and passing it as props to another component to be rendered in that component will not work.

What you are looking for is Slots

Since the complete code is not provided I guess you wanted to render <componentB :name='user1'/> inside another component( a tooltip component)

You would be doing it as follows using slots:

<tooltip-comp>
    <componentB :name='user1'/>
</tooltip-comp>

In your tooltip component

//tooltip component

<template>
    <div class="my-tooltip">
        <p>my tooltip</p>
        <slot></slot>
    </div>
</template>

Leave a comment