// 代码参考:https://segmentfault.com/q/1010000009672767
mounted : function () {
var that = this;
var sortable1 = new Sortable(document.querySelector('#topicNumBox'), {
sort: true,
animation: 300,
onEnd: function (evt) { //拖拽结束发生该事件
that.questionData.splice(evt.newIndex, 0, that.questionData.splice(evt.oldIndex, 1)[0]);
var newArray = that.questionData.slice(0);
that.questionData = [];
that.$nextTick(function () {
that.questionData = newArray;
});
},
});
}
复制代码
详细请参考:sortable.js——Vue 数据更新问题_weixin_33712881的博客-CSDN博客