• 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)
          }
        }
      }
    }
  • 相关阅读:
    swift关键字
    Swift开发注意点
    Mac上安装lua
    Runtime运行时机制
    ios开发中如何选择图片的加载方式
    ios开发中的静态内存分析
    loadrunner-2-9添加事务
    loadrunner-2-8HTML和URL模式
    loadrunner-2-7设置关联
    loadrunner中Windows Resource没有数据或不可用
  • 原文地址:https://www.cnblogs.com/mark21/p/13539176.html
Copyright © 2020-2023  润新知