How to show a different html element/tag based on supplied prop in VueJs
问题 In Vuejs a <template> can only contain one root element, but what to do if you want to render different html element based on a prop? For example, I have a <heading> component which I want to show/render <h1> if title prop, prop: {title: {type: String, required: true}} is title , and show/render <h3> if it is subtitle And that reminds me, what if I want to do this for all h tags ? I mean based on prop condition, show one of these <h1> to <h6> ? 回答1: The is attribute will allow you to