0

I have a question. I have a component called ValidateCheckboxes. ValidateCheckboxes is a validated list of checkboxes. I pass checkboxes to this component by props. It look like that: enter image description here enter image description here I am displaying checkboxes using v-for: enter image description here but my label look like this: enter image description here

How to render custom component from string? Or maybe should I use another way to do that? It's my first question, thanks for answers. :)

I tried use v-html but it didn't work.

2
  • See meta.stackoverflow.com/questions/285551/… . Proceed from the fact that you shouldn't do this, as this makes it much more complicated then it should be. In such cases the slots are usually used Commented Dec 16, 2022 at 10:55
  • Okay, thanks. So should I use slots and avoid using v-for in this case? Commented Dec 16, 2022 at 11:28

1 Answer 1

0

You should use slots, as they provide more control. If you absolutely can't do that because stuff is loaded from a file, database or otherwise fetched from API - you can look into h() and compile() - How I can render a component from a string with vue 3?

Sign up to request clarification or add additional context in comments.

2 Comments

This is more of a comment than an answer
@DouglasGaskell That's a valid point.

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.