vxe-table 个性化列自定义列弹出层修改高度、修改最大高度不自动适应表格高度的方法

vxe-table 个性化列自定义列弹出层修改高度、修改最大高度不自动适应表格高度的方法

默认情况下,在表格设置高度或最小高度的情况下个性化列弹出层默认内部模式(自适应表格高度),表格多高就最大多高;未设置高度情况下默认外部模式(不跟随表格高度)

vxetable.cn

自适应高度时

当 custom-config.poupuOptions.mode='auto' 时,且同时设置高度时

不设置高度时

html 复制代码
<template>
  <div>
    <vxe-radio-group v-model="gridOptions.height">
      <vxe-radio-button checked-value="200" content="高度200"></vxe-radio-button>
      <vxe-radio-button checked-value="" content="不设置高度"></vxe-radio-button>
    </vxe-radio-group>
    <vxe-grid v-bind="gridOptions"></vxe-grid>
  </div>
</template>

<script setup>
import { reactive } from 'vue'

const gridOptions = reactive({
  border: true,
  height: '',
  columnConfig: {
    resizable: true
  },
  toolbarConfig: {
    custom: true
  },
  columns: [
    { type: 'seq', width: 70 },
    { field: 'name', title: 'Name' },
    { field: 'role', title: 'Role' },
    { field: 'sex', title: 'Sex' },
    { field: 'age', title: 'Age' },
    { field: 'attr1', title: 'Attr1' },
    { field: 'attr2', title: 'Attr2' },
    { field: 'attr3', title: 'Attr3' },
    { field: 'attr4', title: 'Attr4' },
    { field: 'address', title: 'Address' }
  ],
  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' },
    { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' }
  ]
})
</script>

强制渲染弹出层为外部模式

强制渲染弹出层为外部模式,可以通过 custom-config.poupuOptions.mode='outside' 来设置,不管有没有设置高度都能超出表格显示,再配置 maxHeight 自定义最大高度

html 复制代码
<template>
  <div>
    <vxe-radio-group v-model="gridOptions.height">
      <vxe-radio-button checked-value="200" content="高度200"></vxe-radio-button>
      <vxe-radio-button checked-value="" content="不设置高度"></vxe-radio-button>
    </vxe-radio-group>
    <vxe-grid v-bind="gridOptions"></vxe-grid>
  </div>
</template>

<script setup>
import { reactive } from 'vue'

const gridOptions = reactive({
  border: true,
  height: '',
  columnConfig: {
    resizable: true
  },
  customConfig: {
    popupOptions: {
      mode: 'outside'
    }
  },
  toolbarConfig: {
    custom: true
  },
  columns: [
    { type: 'seq', width: 70 },
    { field: 'name', title: 'Name' },
    { field: 'role', title: 'Role' },
    { field: 'sex', title: 'Sex' },
    { field: 'age', title: 'Age' },
    { field: 'attr1', title: 'Attr1' },
    { field: 'attr2', title: 'Attr2' },
    { field: 'attr3', title: 'Attr3' },
    { field: 'attr4', title: 'Attr4' },
    { field: 'address', title: 'Address' }
  ],
  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' },
    { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' }
  ]
})
</script>

gitee.com/x-extends/v...

相关推荐
孙克旭_3 小时前
Docker 镜像构建|Vue+SpringBoot+Go 多语言项目 Dockerfile 案例
linux·运维·vue.js·spring boot·docker·dockerfile
雪芽蓝域zzs4 小时前
(六)打包优化 + Nginx 部署完整配置 + 项目收尾
前端·vue.js
宿6746 小时前
vue3-pinia
前端·vue.js
小白勇闯网安圈9 小时前
Vue 进阶实战:事件修饰符、表单控制、购物车与 Ajax 请求
前端·vue.js·ajax
前端炒粉11 小时前
长会话虚拟滚动与渲染优化
前端·javascript·vue.js
sibylyue12 小时前
基于 Vben Admin 框架的 Vue 3 前端项目配置文件及常用命令
前端·javascript·vue.js
小蒜学长15 小时前
vue旅游攻略网站(代码+数据库+LW)
java·数据库·vue.js·spring boot·后端·旅游
sir.山2 天前
在 Vue 3 项目中使用 Mock 数据
前端·vue.js·vue3·vite
你别说话了2 天前
Vue项目解决跨域
前端·javascript·vue.js
学习星球2 天前
Solid.js 实战:拆解官方 RealWorld 项目
开发语言·javascript·vue.js