官方文档
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);
}
GitHub 加速计划 / vu / vue
104
18
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:1 个月前 )
9e887079 [skip ci] 1 年前
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 1 年前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐