How do I switch between different parents element depending on a prop conditional, keeping its content the same?
Example: If Item has isRouter prop, it renders router-link with the needed attributes, otherwise it renders a simple li element.
/* Item.vue */
<router-link v-if="isRouter" tag="li" :to="to" active-class="is-active">
<li v-else>
    /* some html */
    <slot></slot>
    /* more html */
</li>
</router-link>
// View.vue
<list>
  <item isRouter to="/new">
    Breaking News
  </item>
  <item>
    Orange
  </item>
</list>
Is this possible to do? What approach do you advice me to follow?



router-linkandlitags siblings with thev-ifandv-elseconditionals and each with aslotin them, though I haven't tested that. Something to try.slot, so there's some duplication :/