如何在vuetify中水平对齐v-col?

时间:2019-10-21 14:38:53

标签: vue.js vuetify.js

我想将所有七个按钮居中对齐。如您所见,与第一个相比,最后一个有点偏离。

enter image description here

我该如何实现? 我已经尝试过justify="center"justify="space-around"

这是我的代码:

  <v-row no-gutters justify="space-around">
    <v-col v-for="(item, index) in buttons" :key="index">
      <toggle-button
        :weekday="item.weekday"
        :button="item.state"
      ></toggle-button>
    </v-col>
  </v-row>

这里是toggle-button组件:

<template>
  <v-btn
    outlined
    depressed
    :class="button ? 'primary white--text' : 'outlined'"
    @click="button ? (button = false) : (button = true)"
    v-model="button"
    icon
  >
    {{ $t("roomservice.weekdays." + weekday) }}
  </v-btn>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: ["button", "weekday"]
};
</script>

1 个答案:

答案 0 :(得分:2)

v-col不是flex,并且里面的内容(切换按钮)有理由向左开始。

您可以通过在class="d-flex justify-center"上添加v-col来解决此问题

<v-row no-gutters justify="space-around">
    <v-col 
        class="d-flex justify-center"
        v-for="(item, index) in buttons" 
        :key="index">
        <toggle-button
            :weekday="item.weekday"
            :button="item.state"
        ></toggle-button>
    </v-col>
</v-row>
相关问题