zoukankan      html  css  js  c++  java
  • elementUI table怎么实现点击上移下移

    其实炒鸡简单。。。

     

    <el-table :data='tableData' >
    ...
    ...
     <el-table-column label="操作" align="center" width="140" >
             <template slot-scope="scope">
                  <el-button type="text" @click="upMove(scope.$index,scope.row)">上移</el-button>
                  <el-button type="text" @click="upDown(scope.$index,scope.row)">下移</el-button>
              </template>
    </el-table-column>
    </el-table>
     
    export default{
      methods:{   
        upMove(index, row) {
          if (index <= 0) {
            this.$message.error('不能继续向上移动')
          } else {
            const upData = this.tableData[index - 1]
            this.tableData.splice(index - 1, 1)
            this.tableData.splice(index, 0, upData)
          }
        },
        upDown(index, scope) {
          if (index === (this.tableData.length - 1)) {
            this.$message.error('不能继续向下移动')
          } else {
            const downData = this.tableData[index + 1]
            this.tableData.splice(index + 1, 1)
            this.tableData.splice(index, 0, downData)
          }
        }
      }
    }
  • 相关阅读:
    fixed与sticky的区别
    自我介绍以及web课程目标
    DOM&BOM
    web中常用单位的使用
    Oracle 使用 DBLINK详解(转载) 挪威
    Sql server 无法删除用户的处理办法(转载) 挪威
    ICMP类型
    makefile笔记
    [笔记]Makefile wildcard
    在Visual Studio 2005下配置WinPcap开发环境
  • 原文地址:https://www.cnblogs.com/mark21/p/13539176.html
Copyright © 2011-2022 走看看