
vxe-table如何自定义拖拽列宽最小列宽限制,在不改变列min-width的情况下,
例如需要自定义最小列宽的限制,默认是继承 column.min-width 限制,当需要脱离列限制时就有用了
查看官网:https://vxetable.cn
gitbub:https://github.com/x-extends/vxe-table
gitee:https://gitee.com/x-extends/vxe-table
效果
比如 name 这一列设置 min-width=200px,依然可以拖拽成最小列宽,由 resizable-config.minWidth 自定义
<template>
<div>
<vxe-grid v-bind="gridOptions"></vxe-grid>
</div>
</template>
<script setup>
import { reactive } from 'vue'
const gridOptions = reactive({
border: true,
showOverflow: true,
columnConfig: {
resizable: true
},
resizableConfig: {
minWidth: 60
},
columns: [
{ type: 'seq', width: 70 },
{ field: 'name', title: 'Name', minWidth: 200 },
{ field: 'sex', title: 'Sex', minWidth: 120 },
{ field: 'age', title: 'Age', width: 120 },
{ field: 'time', title: 'Time', width: 120 },
{ field: 'address', title: 'Address', minWidth: 160 }
],
data: [
{ id: 10001, name: 'Test1', role: 'Develop', sex: 'Man Man Man', age: 28, address: 'test abc' },
{ id: 10002, name: 'Test2 Test2', role: 'Test Test Test Test Test Test', sex: 'Women', age: 22, address: 'Guangzhou' },
{ id: 10003, name: 'Test3', role: 'PM', sex: 'Man Man Man Man Man Man', age: 32, address: 'Shanghai' },
{ id: 10004, name: 'Test4', role: 'Designer Designer', sex: 'Women', age: 24, address: 'Shanghai' }
]
})
</script>