表格行上移下移

戏子无情 提交于 2019-12-27 14:31:10

【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>

             // 上移
             up(row) {
                if (row.index > 0) {
                  const upDate = this.tableData[row.index - 1];
                  this.tableData.splice(row.index - 1, 1);
                  this.tableData.splice(row.index, 0, upDate);
                  this.$forceUpdate(); // vue $forceUpdate() 强制重新渲染
                } else {
                  this.$message({
                    message: '已经是第一条,不可上移!',
                    type: 'warning'
                  });
                }
              },
             // 下移
              down(row) {
                if (row.index + 1 === this.tableData[i].length) {
                  this.$message({
                    message: '已经是最后一条,不可下移!',
                    type: 'warning'
                  });
                } else {
                  const downDate = this.tableData[row.index + 1];
                  this.tableData.splice(row.index + 1, 1);
                  this.tableData.splice(row.index, 0, downDate);
                }
              },

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!