?第一種思路:利用數(shù)組與對象的關(guān)系:數(shù)組索引就是對象的屬性名key關(guān)系交換位置(原理與二相同都是操作索引)文章來源地址http://www.zghlxwxcb.cn/news/detail-532691.html
html
<el-table :data="collectorData">
<el-table-column prop="name" label="設(shè)備名稱"></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: '已經(jīng)是第一個了?
文章來源:http://www.zghlxwxcb.cn/news/detail-532691.html
到了這里,關(guān)于vue表格某一條數(shù)據(jù)上移、下移的2種思路的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!