简体   繁体   English

Buefy“表格”组件拖放不起作用 - 即使在他们的网站上也不行

[英]Buefy "Table" Component Drag&Drop doesn't work - not even on their website

Well hello, this is my first Question here, so excuse me if im doing anything wrong :).好吧,你好,这是我在这里的第一个问题,所以如果我做错了什么,请原谅:)。

I need a table which is capable of drag&drop for an editor im programming.我需要一个能够为编辑器即时编程拖放的表格。 The Buefy Table component looked really promising, when i tried it on their website in their browser. Buefy Table 组件看起来非常有前途,当我在他们的网站上的浏览器中试用它时。 When I copied the code and tried it, I got the PoP-Up message telling me I moved something, but visually and in my data the elements didn't move at all.当我复制代码并尝试它时,我收到弹出消息,告诉我我移动了一些东西,但在视觉上和我的数据中,元素根本没有移动。 Then I went back to the Buefy Docs, but it didn't work there as well.然后我又回到了 Buefy Docs,但它在那里也不起作用。 How??如何?? I am looking for a fix, or for a workaround using arr.splice().我正在寻找修复方法或使用 arr.splice() 的解决方法。 I tried, but it didn't work.我试过了,但没有用。

Thanks in advance!提前致谢!

//in the component

    dragstart(payload) {
      this.draggingRow = payload.row;
      this.draggingRowIndex = payload.index;
      payload.event.dataTransfer.effectAllowed = 'copy';
    },
    dragover(payload) {
      payload.event.dataTransfer.dropEffect = 'copy';
      payload.event.target.closest('tr').classList.add('is-selected');
      payload.event.preventDefault();
    },
    dragleave(payload) {
      payload.event.target.closest('tr').classList.remove('is-selected');
      payload.event.preventDefault();
    },
    drop(payload) {
      payload.event.target.closest('tr').classList.remove('is-selected');
      const droppedOnRowIndex = payload.index;
      const droppedOnRow = payload.row;
      this.$store.commit('Course/changePos', this.draggingRowIndex, this.draggingRow, droppedOnRowIndex, droppedOnRow);
      this.$buefy.toast.open(`${this.draggingRow.meta.title} von Platz ${this.draggingRowIndex + 1} auf Platz ${droppedOnRowIndex + 1} verschoben.`);
    },

//store:

changePos(s, draggingRowIndex, draggingRow, droppedOnRowIndex, droppedOnRow) {
    state.a.units.splice(droppedOnRowIndex, 1, draggingRow);
    state.a.units.splice(draggingRowIndex, 1, droppedOnRow);
  },


The Code above made one element undefined and didn't change the other one.上面的代码使一个元素未定义并且没有改变另一个元素。

I believe the first argument of splice should be the index .我相信splice的第一个参数应该是index

state.a.units.splice(droppedOnRow, 1, draggingRow);

to

state.a.units.splice(droppedOnRowIndex, 1, draggingRow);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM