element的table实现行拖拽功能,并可以获取到拖拽改变后的表格数据

百度了一番,下面的代码确实可以实现拖拽功能,但是怎么能获取到拖拽后到table数据呢?现在这样取到的数据还是拖拽以前的顺序

  rowDrop() {
      const tbody = document.querySelector('.el-table__body-wrapper tbody')
      const _this = this
      Sortable.create(tbody, {
        onEnd({ newIndex, oldIndex }) {
          const currRow = _this.tableData.splice(oldIndex, 1)[0]
          _this.tableData.splice(newIndex, 0, currRow)
          _this.$nextTick(() => {
            console.log('拖拽后', _this.tableData)
          })
        },
      })
    },
阅读 3.1k
2 个回答

配置项添加forceFallback:true

新手上路,请多包涵

给table添加 row-key

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题