When working with Vue.js, it's important to remember that a <template>
can only have one root element. But what should be done if you need to render different html elements based on a prop?
For instance, let's say we have a <heading>
component where we want to display an <h1>
when the title prop is set to title
, and show an <h3>
if it's set to subtitle
.
This leads to another question - what if we want to achieve this kind of dynamic rendering for all h
tags? In other words, displaying any of these from <h1>
to <h6>
based on certain prop conditions.