<i
class="el-icon-top"
@click="changeIndex(-1,index)"
/>
<i
class="el-icon-bottom"
@click="changeIndex(1,index)"
/>
// 上移下移
changeIndex (type, index) {
console.log(type, index)
let oldItem = {}
let newItem = {}
oldItem = this.dataList[index]
newItem = this.dataList[index + type]
if (index == 0 && type == -1) { // 第一位上移到最后一位
newItem = this.dataList[this.dataList.length - 1]
this.dataList[this.dataList.length - 1] = oldItem
} else if ((index == this.dataList.length - 1) && type == 1) { // 最后一位到第一位
newItem = this.dataList[0]
this.dataList[0] = oldItem
} else {
this.dataList[index + type] = oldItem
}
this.dataList[index] = newItem
this.$forceUpdate()
}
}