vue-dragline

项目根据react-dragline 改写为vue。
github地址:https://github.com/BadMooncc/vue-dragline
支持拖拽辅助线,改变元素大小,元素拖拽功能

演示

屏幕录制2022-04-12 17.56.37

Installation

npm

npm install vue-dragline --save

yarn

yarn add install vue-dragline

全局引入

在入口文件main.js

import Vue from 'vue';
import drag from 'vue-dragline';
import 'vue-dragline/lib/vue-dragline.css';
Vue.use(drag);

Example

<template><draggable-container><draggable-childv-for="item in initialChildren":key="item.id":id="item.id":width="item.width":height="item.height"@stop="handleStop"@start="handleStart"@drag="handleDrag"@resize="handleResize":default-position="item.position"><divclass="item":style="{display: 'flex',flexDirection: 'column',justifyContent: 'center',alignItems: 'center',cursor: 'move',boxSizing: 'border-box',background: item.background,}"><span>size: {{ item.size }}</span><span>drag me</span></div></draggable-child></draggable-container>
</template>
<script>
import 'vue-dragline/lib/vue-dragline.css';
export default {data() {return {initialChildren: [{ id: 1, background: '#8ce8df', width: 100, height: 100, position: { x: 100, y: 10 } },{ id: 2, background: '#8ce8df', width: 100, height: 100, position: { x: 400, y: 106 } },{ id: 3, background: '#d2aff6', width: 100, height: 100, position: { x: 100, y: 316 } },{ id: 4, background: '#fee493', width: 100, height: 100, position: { x: 480, y: 376 } },]};},methods: {handleResize(e) {console.log(e, 'handleResize');},handleDrag(e) {console.log(e);},handleStop(e) {console.log(e, 'handleStop');},handleStart() {console.log('开始');},handleClick() {alert(1);}}
};
</script>

draggable-child组件 Prop Types

Property Type Default Description
id string/number - 元素唯一值,必填
width number - 元素宽度
height number - 元素高度
default-position object {x,y} - 元素元素x,y轴坐标

event事件

resize
改变元素大小时触发,返回元素的当前坐标x,y和宽高wdth,height

stop
元素停止拖拽时触发,返回元素的当前坐标x,y和宽高wdth,height

drag
元素拖拽时触发,返回元素的当前坐标x,y和宽高wdth,height

start
元素被选中时触发,返回元素的当前坐标x,y和宽高wdth,height

vue拖拽辅助线+改变元素大小组件相关推荐

  1. Vue拖拽组件开发实例

    为什么选择Vue? 主要原因:对于前端开发来说,兼容性是我们必须要考虑的问题之一.我们的项目不需要兼容低版本浏览器.项目本身也是一个数据驱动型的.加之,Vue本身具有以下主要特性: 使用虚拟DOM: ...

  2. vue 拖拽元素到任意位置

    vue 拖拽元素到任意位置 使用vue-drag-it-dude组件 npm install vue-drag-it-dude --save 参考地址:https://github.com/xzqyu ...

  3. ant vue 树形菜单横向显示_丝滑般 Vue 拖拽排序树形表格组件Vue-DragTreeTable

    今天给小伙伴们分享一款纵享丝滑般体验的Vue拖拽树形表格DragTreeTable. vue-drag-tree-table 基于vue.js实现可拖拽排序的树形表格组件.支持拖拽排序.固定表头.拖拽 ...

  4. 最好用的 6 款 Vue 拖拽组件库推荐 - 卡拉云

    本文首发:<最好用的 6 款 Vue 拖拽组件库推荐 - 卡拉云> Vue 拖拽组件库(drag-and-drop)组件在使用 Vue 框架开发中非常常见的需求,做个内容行排序,拖拽小组件 ...

  5. 自己封装的vue拖拽组件

    自己封装的vue拖拽组件 使用Vue.Draggable实现 Vue.Draggable的基础使用方法可以看看这个哥们的https://blog.csdn.net/zjiang1994/article ...

  6. vue拖拽排序 组件

    vue拖拽排序 组件 npm install vuedraggable -S vue.draggable中文文档 组件代码 <template><div><div cla ...

  7. vue拖拽组件,从此解放你的双手

    一??vue拖拽.拖拽 它来啦!它来啦! -机智如我一??? 特别简单 ,安装.注册.引用 即可完成拖拽需求 控制台 一??打印拖拽信息一??? 一??1.npm安装 npm install awe- ...

  8. vue拖拽组件(app移动端)

    vue拖拽组件 <template><div id="webId"><!-- 1.1 如果碰到滑动问题,请检查这里是否属于同一点. -->< ...

  9. vue拖拽组件超好用!!!

    vue拖拽组件 在vue实现拖拽,经常使用到,所以自己封装了成了一个组件 效果展示 组件代码 <template><div class="dragBtn" @to ...

最新文章

  1. 大数据与数据挖掘考试题_北京2020届中考物理出题策略大揭秘!
  2. Apache htpasswd命令
  3. JSONObject JSONArray各种用法以及js eval()函数与JSON.parse的区
  4. 轻松构建复杂数据集,永洪自服务数据查询功能详解
  5. mysql 视图操作和存储过程
  6. PIL模块与随机生成中文验证码
  7. ARM-Button-Driver-硬件图
  8. Linux系统中解压缩指令汇总
  9. dokcer mysql修改编码_默认支持utf8编码的mysql docker镜像
  10. WorldView-2数据的预处理
  11. Quartus II使用Testbench
  12. android apk 防止反编译技术第一篇-加壳技术
  13. 学习笔记15--车道线检测
  14. 电子商务中与客户沟通宝典
  15. 如何使用TeamViewer远程控制电脑?三步即可成功
  16. 【CSDN浏览器助手】这款插件忒好用了
  17. 打乱魔方软件_家里魔方吃灰了?这三款魔方App教你轻松上手
  18. CSDN学习(一) -- 什么是CSDN
  19. javaweb项目案例:员工管理系统
  20. 深入计算机组成原理(十五)浮点数和定点数(上):怎么用有限的bit标识尽可能多的信息?

热门文章

  1. Linux网络编程8——线程池模型
  2. OBD数据过滤之:变速箱的里程能不能改
  3. xmos xu208加密
  4. 2.K8S部署-------- 制作CA证书
  5. linux tao环境 安装_菜鸟Linux 编译TAO2.0a的问题,求高手指导
  6. SAP 标准成本、目标成本与实际成本
  7. 右手坐标系下球面参数方程的推导
  8. 转载篇:RabbitMQ安装步骤和出现Plugin configuration unchanged.和出现1067系统错误.总结
  9. NCRE考试感想 三级信息安全(下)
  10. Java小游戏--舒尔特方格