javascript - Vuetify 中大尺寸 v-checkbox 元素的问题

标签 javascript vue.js vuejs2 vue-component vuetify.js

我在 Vue 应用程序中使用 Vuetify,我正在尝试创建一个复选框/文本字段组合(如图所示 here in the Vuetify docs )。但是,当我尝试在我的应用程序中实现它时,复选框元素的大小很大,因此它在复选框和文本字段之间创建了一个很大的空间:

large space after checkbox

这是我正在使用的标记::

<v-container grid-list-lg>
  <v-layout row>
    <v-flex xs1>
      <v-checkbox @change="disableText($event, 'alertBackgroundColor')"></v-checkbox>
    </v-flex>
    <v-flex xs4>
      <v-text-field
        v-bind="fields.alertBackgroundColor"
        v-model="templateModel.alertBackgroundColor"
        placeholder="#4A4A4A"
        :disabled="true"
      />
      </v-flex>
      <v-flex xs1>
        <ColorPickerButton
          v-bind:field-name="'alertBackgroundColor'"
          v-bind:init-color="templateModel.alertBackgroundColor"
          v-on:update-color="getUpdatedColor">
        </ColorPickerButton>
      </v-flex>
      <!-- Alert Text Color -->
      <v-flex xs1>
        <v-checkbox @change="disableText($event, 'alertBackgroundColor')"></v-checkbox>
      </v-flex>
      <v-flex xs4>
        <v-text-field
          v-bind="fields.alertTextColor"
          v-model="templateModel.alertTextColor"
          placeholder="#4A4A4A"
          :disabled="true"
        />
      </v-flex>
      <v-flex xs1>
        <ColorPickerButton
          v-bind:field-name="'alertTextColor'"
          v-bind:init-color="templateModel.alertTextColor"
          v-on:update-color="getUpdatedColor"
        ></ColorPickerButton>
      </v-flex>
    </v-layout>
  </v-container>

如果我修改标记以模仿文档示例,如下所示:

<v-container grid-list-lg>
  <v-layout row>
    <v-flex xs5>
      <v-checkbox @change="disableText($event, 'alertBackgroundColor')""></v-checkbox>
      <v-text-field
        v-bind="fields.alertBackgroundColor"
        v-model="templateModel.alertBackgroundColor"
        placeholder="#4A4A4A"
        :disabled="true"
      />
    </v-flex>
    <v-flex xs1>
      <ColorPickerButton
        v-bind:field-name="'alertBackgroundColor'"
        v-bind:init-color="templateModel.alertBackgroundColor"
        v-on:update-color="getUpdatedColor">
      </ColorPickerButton>
    </v-flex>
  </v-layout>
</v-container>

它们连一条线都放不下:

enter image description here

如何让这两个元素像在文档示例中那样并排组合在一起?问题是元素本身的计算大小,而不是填充或边距,所以使用 spacing helpers没有区别。

最佳答案

您可以尝试将 v-checkboxv-text-field 包装在 v-layout

   <v-layout>
      <v-flex xs5>
        <v-layout>
          <v-checkbox v-model="includeFiles" hide-details class="shrink mr-2"></v-checkbox>
          <v-text-field label="Include files"></v-text-field>
        </v-layout>
      </v-flex>
      <v-flex xs1>Test</v-flex>
    </v-layout>

关于javascript - Vuetify 中大尺寸 v-checkbox 元素的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56066320/

相关文章:

javascript - 使用 router-view 将值传递给所有路由

javascript - 为什么我的 mod_perl 应用程序中的 UTF8 数据在 Web 浏览器中仍然出现乱码?

vue.js - 当 Vue 中第一个输入被填充时禁用第二个输入

javascript - 在 html 部分 View 中以模式显示 dataTable 时出现问题

vue.js $watch 对象数组

javascript - 将样式应用于特定的 v-for 元素

javascript - Vue indexOf vs vanilla javascript 用于从数组中选择对象

javascript - 使用非缩小版本时未定义 Vue 属性或方法

javascript - 从另一个 Observable 数组中过滤 Observable 数组元素

javascript - 在 span/div 标签中表示值的最佳/正确方法是什么?