【推荐】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);
}
},
来源:oschina
链接:https://my.oschina.net/u/3184390/blog/3148125