vue vxe-table 如何实现表格设置默认行高同时又支持自定义行高
在有些产品需求中,列表需要设置默认行高,还得同时支持自适应高度,那么对于这种情况也是可以实现的,首先将默认行高通过 css 变量修改,然后再启用自定义行高,就可以轻松实现这个功能了。

查看官网:
gitbub:
gitee:

例如:设置个默认行高 60px,然后支持超出部分也同时自适应高度

效果

代码

<template>  <div>    <vxe-grid v-bind="gridOptions" class="my-rdah-grid"></vxe-grid>  </div></template><script setup>import { reactive } from 'vue'const gridOptions = reactive({  border: true,  height: 400,  rowConfig: {    resizable: true  },  columns: [    { type: 'seq', width: 70 },    { field: 'name', title: 'Name' },    { field: 'sex', title: 'Sex' },    { field: 'age', title: 'Age' },    { field: 'time', title: 'Time' },    { field: 'address', title: 'Address', width: 300 }  ],  data: [    { id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },    { id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou Guangzhou  Guangzhou' },    { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai Shanghai Shanghai Shanghai Shanghai Shanghai Shanghai Shanghai' },    { id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' },    { id: 10005, name: 'Test5', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' },    { id: 10006, name: 'Test6', role: 'Designer', sex: 'Women', age: 24, address: 'shenzhen' },    { id: 10007, name: 'Test7', role: 'Designer', sex: 'Women', age: 24, address: 'shenzhen shenzhen shenzhen shenzhen shenzhen shenzhen shenzhen shenzhen shenzhen shenzhen' },    { id: 10008, name: 'Test8', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' }  ]})</script><style lang="scss" scoped>.my-rdah-grid {  // 默认行高  --vxe-ui-table-row-height-default: 60px;}</style>

本站提供的所有下载资源均来自互联网,仅提供学习交流使用,版权归原作者所有。如需商业使用,请联系原作者获得授权。 如您发现有涉嫌侵权的内容,请联系我们 邮箱:[email protected]