0

So I have a complex Vue monorepo setup which involves some apps running in Vue2 and some other running in Vue3.

In the monorepo I also got some packages which sometimes expose components (to be consumed by both Vue2 and Vue3 with vue-demi).

The problem is that for some technical requirements I need to have some components defined as a fragment within a table (Several nodes under template), some of it related to a11y . I know that vue3 already allows this but in vue2 is not possible.

So I was tempted to use vue-frag for the vue2 side. What is the issue? That library is not compatible with vue3.

So my question is, is there a possibility to switch between the template's vue3 tag and Fragment from vue-frag ?

Something like:

  // This actually does not work, because it try to interpret template as an HTML tag
 <component :is="isVue2 ? Fragment : 'template'>
   <-- ... --/>
 </component>
SirPeople
  • 4,248
  • 26
  • 46
  • Use v-if and two , I guess. This could be extracted to your own fragment component. You will have more flexibility with render functon. – Estus Flask May 25 '23 at 16:21
  • Really wanted to avoid doing the v-if, because that requires quite some code duplication – SirPeople Jun 01 '23 at 09:33
  • Depends on your case. As said, you can create your own frag comp that does this to avoid duplication – Estus Flask Jun 01 '23 at 18:04
  • How to create my own frag comp for vue3? – SirPeople Jun 06 '23 at 07:14
  • See the first comment. And pass slots and props if needed, it's something like this https://stackoverflow.com/questions/71052398/can-not-loop-through-slots-object-in-vue-3-to-pass-all-slots-from-parent-to-chi – Estus Flask Jun 06 '23 at 07:33

0 Answers0