第一种思路:利用数组与对象的关系:数组索引就是对象的属性名key关系交换位置(原理与二相同都是操作索引)
html
<el-table :data="collectorData">
<el-table-column prop="name" label="设备名称"></el-table-column>
<el-table-column prop="name" label="">
<template slot-scope="scope">
<span class="icon-shangyi-copy-copy-copy iconfont" @click.stop="sortUp(scope.$index, scope.row)"></span>
<span class="icon-shangyi-copy-copy1 iconfont" @click.stop="sortDown(scope.$index, scope.row)"></span>
</template>
</el-table-column>
</>
JAVASCRIPT:
methods:{
// 上移
sortUp(index, row) {
if (index === 0) {//索引==0提示已是第一个不能再向上移动
this.$message({
message: '已经是第一个了ÿ