vxe-table 实现 excel 选择一个单元格拖拽自动复制新的单元格(示例代码)
作者:可不简单
vxe-table是一款强大的表格组件,支持Excel风格的操作,通过鼠标右下角的扩展按钮,用户可以拖拽选择单元格并自动复制内容到扩展区域的所有单元格中,本文通过示例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧
vxe-table 实现 excel 选择一个单元格,拖拽自动复制新的单元格
鼠标按住右下角扩展按钮,当选取一个单元格时,自动将当前内容填充到扩展区域的所有单元格中
<template> <div> <vxe-grid v-bind="gridOptions"></vxe-grid> </div> </template> <script> export default { data () { const gridOptions = { border: true, height: 500, showOverflow: true, columnConfig: { resizable: true }, editConfig: { mode: 'cell', trigger: 'dblclick' // 双击单元格激活编辑状态 }, mouseConfig: { area: true, extension: true // 是否开启区域扩展选取功能,开启后可以通过鼠标左键按住区域内右下角扩展按钮,将区域横向或纵向扩大 }, areaConfig: { extendByCopy: true // 是否启用扩展区域自动填充,当选取一个单元格时,自动将当前内容填充到扩展区域的所有单元格中(同时按住 ctrl 键可取消值自动识别数字功能) }, keyboardConfig: { arrowCursorLock: true, isClip: true, isArrow: true, isShift: true, isTab: true, isEnter: true, isEdit: true, isDel: true, isEsc: true, isFNR: true // 是否开启查找与替换 }, columns: [ { type: 'seq', width: 60 }, { field: 'a', title: 'A', editRender: { name: 'input' } }, { field: 'b', title: 'B', editRender: { name: 'input' } }, { field: 'c', title: 'C', editRender: { name: 'input' } }, { field: 'd', title: 'D', editRender: { name: 'input' } }, { field: 'e', title: 'E', editRender: { name: 'input' } }, { field: 'f', title: 'F', editRender: { name: 'input' } }, { field: 'g', title: 'G', editRender: { name: 'input' } }, { field: 'h', title: 'H', editRender: { name: 'input' } } ], data: [ { id: 10001, a: 'Test1', b: 'Develop', c: 'Man', d: '23', e: '28', f: '', g: '', h: '' }, { id: 10002, a: 'Test2', b: 'Test', c: 'Women', d: '23', e: '22', f: '', g: '', h: '' }, { id: 10003, a: 'Test3', b: 'PM', c: 'Man', d: '23', e: '32', f: '', g: '', h: '' }, { id: 10004, a: 'Test4', b: 'Designer', c: 'Women', d: '456', e: '24', f: '', g: '', h: '' }, { id: 10005, a: 'Test5', b: 'Designer', c: 'Women', d: '23', e: '42', f: '', g: '', h: '' }, { id: 10006, a: 'Test6', b: 'Designer', c: 'Man', d: '23', e: '38', f: '', g: '', h: '' }, { id: 10007, a: 'Test7', b: 'Test', c: 'Women', d: '100', e: '24', f: '', g: '', h: '' }, { id: 10008, a: 'Test8', b: 'PM', c: 'Man', d: '345', e: '34', f: '', g: '', h: '' }, { id: 10009, a: 'Test9', b: 'Designer', c: 'Man', d: '67', e: '52', f: '', g: '', h: '' }, { id: 10010, a: 'Test10', b: 'Test', c: 'Women', d: '23', e: '44', f: '', g: '', h: '' } ] } return { gridOptions } } } </script>
https://gitee.com/x-extends/vxe-table
到此这篇关于vxe-table 实现 excel 选择一个单元格,拖拽自动复制新的单元格的文章就介绍到这了,更多相关vxe-table 拖拽复制单元格内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!