点击按钮传入,下标
<el-button
size="mini"
type="text"
icon="el-icon-top"
@click="move(scope.$index,scope.row)"
v-hasPermi="['sourceData:detectManage:remove']"
>上移</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-bottom"
@click="upDown(scope.$index,row)"
v-hasPermi="['sourceData:detectManage:remove']"
>下移</el-button
>
js 通过数组splice 方法进行删除替换从而实现点击上下移动
// 上移
move(index,row){
if (index <= 0) {
this.$message.error('不能继续向上移动')
} else {
const upData = this.listData[index - 1]
this.listData.splice(index - 1, 1)
this.listData.splice(index, 0, upData)
}
},
// 下移动
upDown(index, scope) {
if (index === (this.listData.length - 1)) {
this.$message.error('不能继续向下移动')
} else {
const downData = this.listData[index + 1]
this.listData.splice(index + 1, 1)
this.listData.splice(index, 0, downData)
}
},
elment ui table 点击上下移动表格
最新推荐文章于 2024-05-30 15:52:26 发布