代码之家  ›  专栏  ›  技术社区  ›  thatOneGuy

如何对Vuejs元素进行分组

  •  0
  • thatOneGuy  · 技术社区  · 8 年前

    假设我有一个组件(mycomponent):

    <template>
       <v-container> <v-container>
    </template>
    

    我想重复使用多次,如何对它们进行分组,这样对用户界面没有影响。例如:

    <myGroup v-if="myStore.property">
      <myComponent/>
      <myComponent/>
      <myComponent/>
      <myComponent/>
      <myComponent/>
    </myGroup>

    这样做的原因是进行检查 v-if="myStore.property" 一次,而不是在每个组件上。

    1 回复  |  直到 8 年前
        1
  •  1
  •   Vamsi Krishna    8 年前

    您可以使用 template 用于分组的标记。

    <template v-if="myStore.property">
      <myComponent/>
      <myComponent/>
      <myComponent/>
      <myComponent/>
      <myComponent/>
    </template>