验证码: 看不清楚,换一张 查询 注册会员,免验证
  • {{ basic.site_slogan }}
  • 打开微信扫一扫,
    您还可以在这里找到我们哟

    关注我们

Vue组件设计之多列表拖拽交换排序功能怎么实现

阅读:578 来源:乙速云 作者:代码code

Vue组件设计之多列表拖拽交换排序功能怎么实现

在前端开发中,拖拽排序是一种提升用户体验非常好的方式,常见的场景有单列表拖拽排序,多列表拖拽交换排序,比如以下这种效果:

Vue组件设计之多列表拖拽交换排序功能怎么实现

 下面将以这种效果为例,设计一个组件。

1. 安装所需依赖

npm install vuedraggable --save

本例中目前所用的版本为:2.20.0

2. 组件设计实现




.dnd-list {
    background: #fff;
    padding-bottom: 40px;
    &:after {
        content: "";
        display: table;
        clear: both;
    }
    .dnd-list-aside {
        float:left;
        padding-bottom: 30px;
        &:first-of-type {
            margin-right: 2%;
        }
        .drag-area{
            margin-top: 15px;
            min-height: 50px;
            padding-bottom: 30px;
        }
    }
}
.list-complete-item {
    cursor: pointer;
    position: relative;
    font-size: 14px;
    padding: 5px 12px;
    margin-top: 4px;
    border: 1px solid #bfcbd9;
    transition: all 1s;
}
.list-complete-item-handle1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 50px;
}
.list-complete-item-handle2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 20px;
}
.list-complete-item.sortable-chosen {
    background: #4ab7bd;
}
.list-complete-item.sortable-ghost {
    background: #30b08f;
}
.list-complete-enter,.list-complete-leave-active {
    opacity: 0;
}

3. 组件使用示例




.box{
    width:600px;
    margin:20px;
    padding:10px;
    background:#fff;
}
分享到:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: hlamps#outlook.com (#换成@)。
相关文章
{{ v.title }}
{{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
你可能感兴趣
推荐阅读 更多>