调整 vuetify 项目的高度

迭戈·蒙萨尔维

我正在用 vuetify 创建一个简单的表格,结果发现当添加v-radio-group组件时,行中的元素没有调整到高度,所以这导致表格看起来很难看。

我可以使用什么属性使 cols 都适合相同的高度。我查看了几个地方,甚至在文档中也没有看到类似的内容。

成分:

          <template>
        <v-container>
          <v-row class="text-center" no-gutters>
            <v-col v-for="(item, index) in headers" v-bind:key="index">
              <v-card v-if="item" :key="index" class="pa-2" outlined tile>
                {{ item.nombre }}
              </v-card>
            </v-col>
          </v-row>

          <div v-for="(item, index) in items" v-bind:key="index">
            <v-row no-gutters class="text-center"
            align="center"
            >
              <v-col
              align-self="center"
              >
                <v-card class="pa-2" outlined tile>
                  {{ item.nombre }}
                </v-card>
              </v-col>
              <v-col>
                <v-card class="pa-2" outlined tile>
                  {{ item.cantidad }}
                </v-card>
              </v-col>
              <v-col offset-md="12">
                <v-card outlined tile>
                  <v-radio-group v-model="radioGroup">
                    <v-radio
                      v-for="n in 2"
                      :key="n"
                      :label="`Radio ${n}`"
                      :value="n"
                    ></v-radio>
                  </v-radio-group>
                </v-card>
              </v-col>
            </v-row>

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

      <script>
      export default {
        name: "HelloWorld",
        data() {
          return {
            optRadio: [
            { nombre: "Bueno", value: 1}, 
            { nombre: "Malo", value: 2}, 

            ],
            headers: [
              { nombre: "Descripcion", value: "descripcion" },
              { nombre: "Cantidad", value: "cantidad" },
              { nombre: "estado", value: "state" },
            ],
            items: [
              { nombre: "RADIO", cantidad: 1, state: 1 },
              { nombre: "FRONTAL", cantidad: 10, state: 0 },
              { nombre: "PARLANTES", cantidad: 100, state: 2 },
              { nombre: "ENCENDEDOR", cantidad: 100, state: 2 },
              { nombre: "CENICERO", cantidad: 100, state: 2 },
              { nombre: "TAPETES", cantidad: 100, state: 2 },
            ],
          };
        },
      };
      </script>
安祖派

这里的关键是将正确的 flex 属性应用到您的网格系统。

首先,您必须指示您的列垂直放置内容,而不是水平放置: <v-col class="d-flex flex-column"

然后,指示其中的卡片在可用的垂直高度上增长:<v-card class="pa-2 flex-grow-1 d-flex" outlined tile>要使内容在卡片中居中,请将这两个 flex 助手添加到卡片中:align-center justify-center

文档在这里Codepen 解决方案在这里

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章