ant table表头行列拖拽切换位置
import Sortable from 'sortablejs'
// 行拖拽 rowDrop() { const tbody = document.querySelector('.ant-table-tbody') // 元素选择器名称根据实际内容替换 const _this = this Sortable.create(tbody, { // 官网上的配置项,加到这里面来,可以实现各种效果和功能 animation: 150, ghostClass: 'blue-background-class', onEnd({ newIndex, oldIndex }) { const currRow = _this.tableData.splice(oldIndex, 1)[0] _this.tableData.splice(newIndex, 0, currRow) } }) }, /** 列拖拽 */ columnDrop() { const wrapperTr = document.querySelector('.ant-table-thead tr') this.sortable = Sortable.create(wrapperTr, { animation: 180, delay: 0, onEnd: (evt) => { const oldItem = this.tableColumns[evt.oldIndex] this.tableColumns.splice(evt.oldIndex, 1) this.tableColumns.splice(evt.newIndex, 0, oldItem) } }) },
rankingList(params) .then((res) => { this.tableData = res.records this.pageObj.total = Number(res.total) this.pageObj.current = Number(res.current) this.columnDrop() // 获取完数据智慧调用 // this.pageObj.size = res.size }) .finally((e) => { this.tableLoading = false })
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现