Conditional tag ending in Vue.js

时间:2018-02-26 17:56:55

标签: vue.js vuejs2 conditional vue-component

I'm trying to do a conditional tag ending, but this isn't working. Is there a work around?

    <div class="container">

    <template v-if="smallScreen"> 
         </div>
    </template>

    <template v-else> 
         </div>
    </template>

Thanks! William

1 个答案:

答案 0 :(得分:2)

I can understand why you require this kind of situation. But alas, there's no such a way to fulfill this situation to be solved as of now with Vue.js.

You must coverage them with a wrapper:

<div class="container" v-if="smallScreen">
  <template></template>
</div>
<div class="container" v-else>
  <template>Another Template</template>
</div>