niclas_4
niclas_4

Reputation: 3674

best practise to render html strings that contain components in vue

I have a Blog/News kind of Website which means there will be Posts, they have a content which is a string of HTML stored in my database.

Since I also need stuff like Sliders and so on which won´t get generated via v-html I thought about what is the best practice to render a HTML String I retrieve from the Database on the Website Frontend.

I readed the Vue Docs about Render Functions but wasn´t able to solve my problem with the information there.

Example HTML String for understanding

<div class="slidercontainer">
   <slider :options="optionPreset1"></slider>
</div>

I save those presets in the finished Post Component. If there is any better way to solve this kind of thing with a DB then tell me, its not in Production yet so I can change such crucial things.

Upvotes: 2

Views: 800

Answers (1)

Roy J
Roy J

Reputation: 43899

You need to use dynamic components. See this answer.

Upvotes: 1

Related Questions