news 2026/8/15 14:59:45

vxe-table 实现服务端排序的用法

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
vxe-table 实现服务端排序的用法

vxe-table 实现服务端排序的用法

https://vxetable.cn

配置 sort-config.remote 和 sort-change 事件,实现服务端排序

<template><div><vxe-gridv-bind="gridOptions"@sort-change="sortChangeEvent"></vxe-grid></div></template><script>importXEUtilsfrom'xe-utils';exportdefault{data(){constgridOptions={border:true,loading:false,height:400,columnConfig:{resizable:true},sortConfig:{remote:true},columns:[{type:'seq',width:70},{field:'name',title:'Name'},{field:'role',title:'Role',sortable:true},{field:'sex',title:'Sex',sortable:true},{field:'age',title:'Age',sortable:true},{field:'address',title:'Address',sortable:true}],data:[]};return{gridOptions};},methods:{findList(field,order){this.gridOptions.loading=true;// 模拟接口returnnewPromise(resolve=>{setTimeout(()=>{this.gridOptions.loading=false;constmockList=[{id:10001,name:'Test1',role:'Develop',sex:'Man',age:28,num:'3.8',num2:'3.8',address:'test abc'},{id:10002,name:'Test2',role:'Test',sex:'Women',age:22,num:'511',num2:'511',address:'Guangzhou'},{id:10003,name:'Test3',role:'PM',sex:'Man',age:32,num:'12.8',num2:'12.8',address:'Shanghai'},{id:10004,name:'Test4',role:'Designer',sex:'Women',age:23,num:'103',num2:'103',address:'test abc'},{id:10005,name:'Test5',role:'Develop',sex:'Women',age:30,num:'56',num2:'56',address:'Shanghai'},{id:10006,name:'Test6',role:'Designer',sex:'Women',age:21,num:'49',num2:'49',address:'test abc'},{id:10007,name:'Test7',role:'Test',sex:'Man',age:29,num:'400.9',num2:'400.9',address:'test abc'},{id:10008,name:'Test8',role:'Develop',sex:'Man',age:35,num:'5000',num2:'5000',address:'test abc'}];if(field&&order){constrest=XEUtils.orderBy(mockList,{field,order});this.gridOptions.data=rest;resolve(rest);}else{this.gridOptions.data=mockList;resolve(mockList);}},300);});},sortChangeEvent({field,order}){this.findList(field,order);}},created(){this.findList();}};</script>

https://gitee.com/x-extends/vxe-table

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/8/16 8:46:47

ThinkPad P53风扇控制优化:从过热困扰到完美散热解决方案

ThinkPad P53风扇控制优化&#xff1a;从过热困扰到完美散热解决方案 【免费下载链接】TPFanCtrl2 ThinkPad Fan Control 2 (Dual Fan) for Windows 10 and 11 项目地址: https://gitcode.com/gh_mirrors/tp/TPFanCtrl2 作为一名ThinkPad P53的长期用户&#xff0c;你是…

作者头像 李华
网站建设 2026/8/16 9:44:01

超详细版WinDbg蓝屏问题诊断过程

深入Windows内核&#xff1a;用WinDbg破解蓝屏背后的真相 你有没有遇到过这样的场景&#xff1f;一台关键服务器突然黑屏&#xff0c;屏幕上跳出刺眼的蓝色错误界面——“你的设备遇到问题&#xff0c;需要重启”。日志里只留下一句模糊的提示&#xff1a;“意外停止”&#x…

作者头像 李华
网站建设 2026/8/15 16:09:50

如何快速获取网盘直链:新手的完整解决方案

如何快速获取网盘直链&#xff1a;新手的完整解决方案 【免费下载链接】Online-disk-direct-link-download-assistant 可以获取网盘文件真实下载地址。基于【网盘直链下载助手】修改&#xff08;改自6.1.4版本&#xff09; &#xff0c;自用&#xff0c;去推广&#xff0c;无需…

作者头像 李华
网站建设 2026/8/16 9:44:40

手机号查QQ终极指南:Python实现的隐私安全一键查询神器

手机号查QQ终极指南&#xff1a;Python实现的隐私安全一键查询神器 【免费下载链接】phone2qq 项目地址: https://gitcode.com/gh_mirrors/ph/phone2qq 你是否曾经遇到过这样的情况&#xff1a;某个重要的手机号需要找到对应的QQ号&#xff0c;却苦于没有合适的工具&am…

作者头像 李华
网站建设 2026/8/15 5:20:17

终极AMD处理器性能调优:SMUDebugTool完整使用指南

终极AMD处理器性能调优&#xff1a;SMUDebugTool完整使用指南 【免费下载链接】SMUDebugTool A dedicated tool to help write/read various parameters of Ryzen-based systems, such as manual overclock, SMU, PCI, CPUID, MSR and Power Table. 项目地址: https://gitcod…

作者头像 李华
网站建设 2026/8/13 21:13:19

思源黑体TTF:解锁多语言设计的7个重量级免费字体方案

思源黑体TTF&#xff1a;解锁多语言设计的7个重量级免费字体方案 【免费下载链接】source-han-sans-ttf A (hinted!) version of Source Han Sans 项目地址: https://gitcode.com/gh_mirrors/so/source-han-sans-ttf 在全球化的数字时代&#xff0c;一款能够完美支持中日…

作者头像 李华