在 vue 项目中使用拖拽表格 发表于 2020-05-26 | 分类于 随笔 | 评论数: | 阅读次数: element-ui 中的 table 组件无法满足自定义拖拽的需求,因此我们使用 sortablejs 中的 vuedraggable来实现. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354<template> <div class="row"> <div class="col-8"> <h3>Draggable table</h3> <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> <rawDisplayer class="col-3" :value="list" title="List" /> </div></template><script>import draggable from "@/vuedraggable";export default { name: "table-example", display: "Table", order: 8, components: { draggable }, 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" } ], dragging: false }; }};</script><style scoped>.buttons { margin-top: 35px;}</style> 效果如图: 参见: Vue.Draggable sortable thank u ! 打赏 微信支付