[状态管理 mobx](https://cn.mobx.js.org/)import { observable ,action, toJS } from 'mobx';@observable DataSource = []; // 表格列表数据@observable selectedObj = {}; // 选中的数据@observable selectedRowKey = ''; // 当前行index// 上移@action MoveUp(){ // 下面三行代码意思就相当于冒泡排序 替换ordernum这个值 let x = this.selectedRowKey let orderNum = this.DataSource[x- 1].orderNum; // 点击当前行index的上一条数据(根据index获取数据) this.DataSource[x - 1].orderNum = this.DataSource[x].orderNum; // 上移的orderNum 等于 当前点击数据的orderNum this.DataSource[x].orderNum = orderNum; // 当前数据的orderNum 等于上移orderNum this.selectedObj.orderNum = orderNum; // 使用splice来交换数据 this.DataSource .splice(x- 1, 1, ...this.DataSource .splice((x+ 1) - 1, 1, this.DataSource[x - 1]));}// 下移@action moveDown(){ // 同理上移 let x = this.selectedRowKey + 1; let y = this.selectedRowKey + 2; let a = this.selectedRowKey; let orderNum = this.DataSource[a + 1].orderNum; this.DataSource[a + 1].orderNum = this.DataSource[a].orderNum; this.DataSource[a].orderNum = orderNum; this.selectedObj.orderNum = orderNum; this.DataSource .splice(x - 1, 1, ...this.DataSource .splice(y - 1, 1, this.DataSource[x - 1]))}