我想创建一个vue页面,其中有两个数据表(垂直)占据半个屏幕.如果需要,每个数据表都应该有一个滚动条.

我try 了下面的标记,但这并没有将数据表调整到屏幕大小.这是codepen example美元

<div id="app">
    <v-app id="inspire">
    <v-container fluid grid-list-md fill-height>
      <v-layout column>
        <v-flex md6>
          <v-data-table
            :headers="headers"
            :items="desserts"
            hide-actions
            class="elevation-1"
          >
            <template slot="items" slot-scope="props">
              <td>{{ props.item.name }}</td>
              <td class="text-xs-right">{{ props.item.calories }}</td>
              <td class="text-xs-right">{{ props.item.fat }}</td>
              <td class="text-xs-right">{{ props.item.carbs }}</td>
              <td class="text-xs-right">{{ props.item.protein }}</td>
              <td class="text-xs-right">{{ props.item.iron }}</td>
            </template>
          </v-data-table>
          </v-flex>
        <v-flex md6>
          <div>
          <v-data-table
            :headers="headers"
            :items="desserts"
            hide-actions
            class="elevation-1"
          >
            <template slot="items" slot-scope="props">
              <td>{{ props.item.name }}</td>
              <td class="text-xs-right">{{ props.item.calories }}</td>
              <td class="text-xs-right">{{ props.item.fat }}</td>
              <td class="text-xs-right">{{ props.item.carbs }}</td>
              <td class="text-xs-right">{{ props.item.protein }}</td>
              <td class="text-xs-right">{{ props.item.iron }}</td>
            </template>
          </v-data-table>
          </div>
        </v-flex>
      </v-layout>
    </v-container>
    </v-app>
</div>

推荐答案

为了获得结果,我需要在布局上将高度设置为100vh,并在每个flex上设置溢出.我已经更新了有问题的代码笔

<div id="app">
<v-app id="inspire">
 <v-container>
  <v-layout column style="height: 90vh">       <--- added height
    <v-flex md6 style="overflow: auto">        <--- added overflow
      <v-data-table
        :headers="headers"
        :items="desserts"
        hide-actions
        class="elevation-1"
      >
        <template slot="items" slot-scope="props">
          <td>{{ props.item.name }}</td>
          <td class="text-xs-right">{{ props.item.calories }}</td>
          <td class="text-xs-right">{{ props.item.fat }}</td>
          <td class="text-xs-right">{{ props.item.carbs }}</td>
          <td class="text-xs-right">{{ props.item.protein }}</td>
          <td class="text-xs-right">{{ props.item.iron }}</td>
        </template>
      </v-data-table>
      </v-flex>
    <v-flex md6 style="overflow: auto">        <--- added overflow
      <v-data-table
        :headers="headers"
        :items="desserts"
        hide-actions
        class="elevation-1"
      >
        <template slot="items" slot-scope="props">
          <td>{{ props.item.name }}</td>
          <td class="text-xs-right">{{ props.item.calories }}</td>
          <td class="text-xs-right">{{ props.item.fat }}</td>
          <td class="text-xs-right">{{ props.item.carbs }}</td>
          <td class="text-xs-right">{{ props.item.protein }}</td>
          <td class="text-xs-right">{{ props.item.iron }}</td>
        </template>
      </v-data-table>
    </v-flex>
  </v-layout>
 </v-container>
</v-app>

Vue.js相关问答推荐

如何将$validator实例注入到使用组合API语法的Vue2.7应用程序中

如何在与父集合相同的读取中取回子集合(或重构数据?)

使用V-TOOLTIP(实例化)使工具提示在V-文本字段中显示清晰的图标

如何 for each 动态创建的按钮/文本字段设置唯一变量?

:deep() 带有嵌套 scss 规则的语法

在 bootstrap-vue 中渲染自定义样式

如何 for each 用户分组聊天消息?

使用 v-slot:body 时 Vuetify v-data-table 没有响应

Vue-router:循环路由以动态创建

将检测外部点击自定义指令从 Vue 2 迁移到 Vue 3

Vue.js 过滤数组

在 SPA VueJS 中全局声明 mapState 和 mapMutations

POST 文件连同表单数据 Vue + axios

等待来自 WDS 的更新信号

Vue.js 无法切换字体真棒图标

在组件之间共享数据

使用props向组件添加类名

在 VUE JS 的光标位置插入字符

Vue如何将动态ID与v-for循环+字符串中的字段连接起来?

在 Vue 应用程序中创建一个类的单个实例