0

How can I render a component inside a template using text interpolation? I tried the following code:

<template>
   <div> {{ booleanValue ? "<my-component />" : "Some Text" }} </div>
</template>

But this is printing the actual code with the "double mustaches", removing the component tag and also rendering the component.

{{ booleanValue ? "" : "Some Text" }}

1 Answer 1

1

I still don't know how to do it with text interpolation, but I found a simpler way to this: Conditional Rendering

 <div v-if="booleanValue"> 
    <my-component /> 
 </div>
 <div v-else>Some Text</div>
Sign up to request clarification or add additional context in comments.

1 Comment

This is the correct way to do it. Text interpolation is - wait for it - text only. No components.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.