普通视图

发现新文章,点击刷新页面。
今天 — 2026年1月30日首页

vue2 甘特图 vxe-gantt 一行渲染多个子任务的配置

作者 自由的云h
2026年1月30日 11:21

vue2 甘特图 vxe-gantt 一行渲染多个子任务的配置,但需要在父级任务直接显示所有子任务时,可以通过 task-bar-subview-config 和父级任务设置type= VxeGanttTaskType.Subview 来设置,会自动将所有子任务渲染到父级任务中

gantt.vxeui.com

在这里插入图片描述 设置 task-bar-subview-config.showOverview 设置是否任务总览,当子任务被展开后自动显示任务总览

<template>
  <div>
    <vxe-gantt v-bind="ganttOptions"></vxe-gantt>
  </div>
</template>

<script>
import { VxeGanttTaskType } from 'vxe-gantt'

export default {
    data() {
        const ganttOptions = {
              border: true,
  treeConfig: {
    transform: true,
    rowField: 'id',
    parentField: 'parentId'
  },
  taskConfig: {
    startField: 'start',
    endField: 'end',
    typeField: 'type',
    progressField: 'progress'
  },
  taskBarSubviewConfig: {
    showOverview: true 
  },
  taskBarConfig: {
    showContent: true,
    barStyle: {
      round: true
    }
  },
  taskViewConfig: {
    tableStyle: {
      width: 280
    }
  },
  columns: [
    { field: 'title', title: '任务名称', minWidth: 140, treeNode: true },
    { field: 'start', title: '开始时间', width: 100 },
    { field: 'end', title: '结束时间', width: 100 },
    { field: 'progress', title: '进度(%)', width: 80 }
  ],
  data: [
    { id: 10001, parentId: null, title: '我的项目1', start: '', end: '', progress: 0, type: VxeGanttTaskType.Subview },
    { id: 10002, parentId: 10001, title: '我的项目2', start: '2024-03-02', end: '2024-03-05', progress: 70 },
    { id: 10003, parentId: null, title: '我的项目3', start: '', end: '', progress: 0, type: VxeGanttTaskType.Subview },
    { id: 10004, parentId: 10003, title: '我的项目4', start: '2024-03-03', end: '2024-03-04', progress: 50 },
    { id: 10005, parentId: 10003, title: '我的项目5', start: '2024-03-05', end: '2024-03-06', progress: 50 },
    { id: 10006, parentId: 10003, title: '我的项目6', start: '2024-03-08', end: '2024-03-11', progress: 60 },
    { id: 10008, parentId: null, title: '我的项目7', start: '', end: '', progress: 0, type: VxeGanttTaskType.Subview },
    { id: 10009, parentId: 10008, title: '我的项目8', start: '2024-03-07', end: '2024-03-09', progress: 50 },
    { id: 10010, parentId: 10008, title: '我的项目9', start: '2024-03-10', end: '2024-03-12', progress: 50 },
    { id: 10011, parentId: 10008, title: '我的项目10', start: '2024-03-13', end: '2024-03-15', progress: 50 }
  ]
        };
        return {
            ganttOptions
        };
    }
};
</script>

gitee.com/x-extends/v…

昨天以前首页

vue 表格 vxe-table 如何设置列默认不显示,用户可以手动通过工具栏设置显示

作者 自由的云h
2026年1月27日 12:41

vue 表格 vxe-table 如何设置列默认不显示,用户可以手动通过工具栏设置显示。实现该方式非常简单,可以通过列的 visible 属性设置为默认不显示,然后用户可以在工具栏的自定义列里面勾选显示或隐藏。自定义方式就很方便了。

vxetable.cn

table_custom_def_hide

通过设置 toolbar-config.custom 启用列个性化设置功能,然后将列的 visible=false 设置为默认隐藏,用户可以通过自定义勾选显示;还可以设置是否否禁用,拖拽排序,冻结列等

<template>
  <div>
    <vxe-grid v-bind="gridOptions"></vxe-grid>
  </div>
</template>

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

const gridOptions = reactive({
  border: true,
  toolbarConfig: {
    custom: true
  },
  columns: [
    { field: 'seq', type: 'seq', width: 70 },
    { field: 'role', title: 'Role', visible: false },
    { field: 'name', title: 'Name' },
    { field: 'sex', title: 'Sex' },
    { field: 'age', title: 'Age' },
    { field: 'address', title: 'Address', visible: false }
  ],
  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' },
    { id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' }
  ]
})
</script>

多种显示模式

自定义列弹出层支持多种方式,可以设置为弹出层,窗口,抽屉等方式.

通过设置 custom-config.mode='modal' 启用窗口模式

image

设置 custom-config.mode='drawer' 启用窗口模式

image

gitee.com/x-extends/v…

❌
❌