1

For example I have a template and some other <my-component>:

template: '<i data-toggle="popover" data-html="true" data-content="**Here I need render another  component in loop**"></i>'

This

 :data-content="<my-component v-for... ></my-component>"

doesn't work. Perhaps there is a method to render my-component in another place ? In computed area... or in methods ?

So, how can I render component in html data-*attributes ?

Thank you.

2
  • What's the reason to have HTML inside data attribute? If you really need it, try to insert plain html string, not as a component. But it looks super invalid Commented Jul 26, 2018 at 11:48
  • @Anarion The reason is simple - Bootstrap Popover :) Commented Jul 26, 2018 at 12:48

1 Answer 1

1

You will have to convert your component to be functional. Read Introduction to Vue.js Render Functions and Render Functional Components in Vue.js

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

4 Comments

Wich exactly component should I to convert ? Do I have to remove <my-component> and move it's functionality to the render function in my parent component ?
You should convert the component which you want to put inside the data-content attribute. The new functional component will be returning a DOM-fragment so you can easily get its innerHTML.
Sorry for the my arrogance, but can You illustrate it, very briefly, I can not understand some things and my English does not allow me a more specific question. Thank You.
Hm, it seems that it would be simpler for you to avoid mixing Vue and jQuery stuff. If you insist on doing so perhaps you can have <my-component ref="my"> somewhere inside your parent with v-show="false" and then inside the mounted() handler get the this.$refs.my.innerHTML and provide it to the data-content attribute of your popover. But this is too hacky - you'd be better stick with pure Vue-compatible 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.