LogicFlow(Vue3)

官方文档
GITEE 小demo
在这里插入图片描述

步骤1.安装

//LogicFlow
npm install @logicflow/core --save

//LogicFlow组件
npm install @logicflow/extension --save

快速上手

参考官网案例

// 创建容器
<div id="container"></div>

// 准备数据
const data = {
  // 节点
  nodes: [
  {id: 21, type: 'rect',x: 100,y: 200,text: {value: '矩形节点',x: 100,y: 200}},
  {id: 50,type: 'circle', x: 300,y: 400,text: {value: '圆形节点',x: 300,y: 400}},
  ],
  // 边
  edges:[
    {type: 'polyline', sourceNodeId: 50,targetNodeId: 21 }
  ]
}
// 渲染画布
const lf = new LogicFlow({
  container: document.querySelector('#container'),
  width: 700,
  height: 600,
});

lf.render(data);

步骤2.准备节点侧边栏

<!--组件栏-->
<div class="node-panel">
    <div class="node-item" @mousedown='methods.mouseDownHandle(item)' v-for="(item,index) in shapeList" :key="index">
         <div class="node-item-icon" :class="item.class">
               <span class="node-label">{{item.text}}</span>
         </div>
    </div>
</div>

节点数据

 shapeList: [
    {type: 'rect', text: '矩形',class:'node-rect'},
    {type: 'circle', text: '圆形',class:'node-circle'},
    {type: 'ellipse', text: '椭圆',class:'node-ellipse'},
    {type: 'polygon', text: '多边形',class:'node-polygon'},
    {type: 'my-rect', text: '自定义',class:'node-rect'},
],

拖拽事件 @mousedown:methods.mouseDownHandle(item)

 /**
  * 拖拽
  * @param item 拖拽属性
  */
mouseDownHandle : function (item) {
    data.lf.dnd.startDrag({
          type:item.type,
          text:item.text,
          properties:{}
    });
},

侧边栏的node样式(非专业前端,样式讲究凑合着看吧)

.node-panel {
    width: 70px;
    padding: 20px 0;
    background-color: white;
    box-shadow: 0 0 10px 1px rgb(228, 224, 219);
    border-radius: 6px;
    text-align: center;
    z-index: 101;
}
.node-item {
    margin-bottom: 20px;
}
.node-item-icon {
    width: 30px;
    height: 30px;
    margin-left: 20px;
    background-size: cover;
    text-align: center;
}
.node-label {
    font-size: 12px;
    margin-top: 5px;
    user-select: none;
}
.node-rect{
    width: 40px;
    height: 30px;
    border: 2px solid black;
}
.node-circle{
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid black;
}
.node-ellipse{
    border: 2px solid black;
    border-radius: 60%;
    width: 40px;
    height: 30px;
}
.node-polygon{
    width: 40px;
    height: 40px;
    border: 2px solid black;
    transform:rotate(45deg);
}
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小草王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值