表格行拖动排序?element ui + vue + Sortable

 先来看看效果

表格拖拽操作

安装Sortable
npm i sortablejs --save

在需要使用的地方引入Sortable

import Sortable from 'sortablejs'
使用方法

首先要给表格加上 row-key="id",因为我这里有三个联动的表格,所以给每个表格加上了唯一id


        <el-table
          ref="dataTable"
          :data="sceneList"
          highlight-current-row
          border
          row-key="id"
          id="sence-tbody"
          style="width: 100%"
          :header-cell-style="{
            background: '#f0f0f0',
            color: '#333',
            height: '28px'
          }"
          :row-style="{ height: '28px' }"
          :cell-style="{ padding: '4px' }"
        >
          <el-table-column
            align="center"
            type="index"
            width="50"
          ></el-table-column>
          <el-table-column
            header-align="center"
            align="left"
            label="场景名称"
            prop="name"
          ></el-table-column>
        
          <el-table-column width="160" align="center" label="操作">
            <template slot-scope="scope">
              <el-button size="mini" type="text" @click="detailPord(scope.row)"
                >查看产品</el-button
              >
            </template>
          </el-table-column>
        </el-table>

       <el-table
        ref="pordTable"
        :data="produceList"
        highlight-current-row
        border
        row-key="id"
        id="pord-tbody"
        style="width: 100%"
        :header-cell-style="{
          background: '#f0f0f0',
          color: '#333',
          height: '28px'
        }"
        :row-style="{ height: '28px' }"
        :cell-style="{ padding: '2px' }"
      >
        <el-table-column
          align="center"
          type="index"
          width="50"
        ></el-table-column>
        <el-table-column
          header-align="center"
          align="left"
          label="产品名称"
          prop="name"
        ></el-table-column>
        <el-table-column align="center" width="280" label="操作">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="showChild(scope.row, 822746444562432, (showTable = 1))"
              >功能模块</el-button
            >
          </template>
        </el-table-column>
      </el-table>

       <el-table
        ref="childTable"
        :data="moduleList"
        highlight-current-row
        border
        row-key="id"
        i
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值