如何使 Vue 可排序在桌面上工作?



我对这个库有问题。首先,为了测试库,我做了一个简单的示例,使用 ul 和 li 标签。这很简单。然后,我需要做一个表,当将我的示例转换为表时,它不起作用。

显示表格,但我无法移动任何行。

我正在使用 cdn 方式。

我认为是我所缺少的。

.html

<div id='app-example-drag' >
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th scope="col">Id</th>
<th scope="col">Name</th>
<th scope="col">Sport</th>
</tr>
</thead>
<draggable v-model="list" tag="tbody">
<tr v-for="item in list" :key="item.name">
<td scope="row">{{ item.id }}</td>
<td>{{ item.name }}</td>
<td>{{ item.sport }}</td>
</tr>
</draggable>
</table>
</div>

.js

Vue.component('draggable',vuedraggable);
applicationExample = new Vue({
el: '#app-example-drag',
display: "Table",
order: 8,
data() {
return {
list: [
{ id: 1, name: "Abby", sport: "basket" },
{ id: 2, name: "Brooke", sport: "foot" },
{ id: 3, name: "Courtenay", sport: "volley" },
{ id: 4, name: "David", sport: "rugby" }
]
};
}
});

https://jsfiddle.net/0Luhd694/3/

提前致谢

我刚刚遇到了同样的问题。我认为它与最新版本有关。将可拖动元素替换为 tbody 并使 is='draggable'。

<div id='app-example-drag' >
<table class='table'>
<thead>
<tr><th scope='col'>description</th></tr>
</thead>
<tbody tag='tbody' v-model='lista1' is='draggable' group='items'>
<tr v-for='item in lista1' :key='item.id'>
<td scope='row'>{{item.description}}</td>
</tr>
</tbody>
</table>
</div>

https://jsfiddle.net/oqf64kdx/

最新更新