官网

Vue Flow 官网

Vue Flow GitHub

安装

npm i --save @vue-flow/core

yarn add @vue-flow/core

pnpm i @vue-flow/core

使用

<template>
<VueFlow v-model="elements" />
</template> <script setup>
import { VueFlow } from '@vue-flow/core' const elements = ref([
// Nodes
// An input node, specified by using `type: 'input'`
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } }, // Default nodes, you can omit `type: 'default'`
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 } }, // An output node, specified by using `type: 'output'`
{ id: '4', type: 'output', label: 'Node 4', position: { x: 400, y: 200 } }, // Edges
// Most basic edge, only consists of an id, source-id and target-id
{ id: 'e1-3', source: '1', target: '3' }, // An animated edge
{ id: 'e1-2', source: '1', target: '2', animated: true },
])
</script> <style>
/* these are necessary styles for vue flow */
@import "@vue-flow/core/dist/style.css"; /* this contains the default theme, these are optional styles */
@import "@vue-flow/core/dist/theme-default.css";
</style>

常用功能:

  1. 画布居中
import { VueFlow, useVueFlow } from "@vue-flow/core";
const { onPaneReady } = useVueFlow();
const state = reactive({
instance: null,
});
onPaneReady((instance) => {
instance.fitView();
// 将对象缓存
state.instance = instance;
}); // 设置缩放级别
state.instance.fitView({ offset: { y: 50 } });
state.instance.zoomTo(1);
  1. 点击事件
  <VueFlow
v-model="flowElement"
:style="{ background: 'transparent' }"
:default-zoom="1"
fit-view-on-init
@nodeClick="nodeClickHandler"
/>
const nodeClickHandler = (props) => {
const node = props.node;
console.log(node.id);
};

最新文章

  1. 关于SSH的一些tricks
  2. 修改mysql默认字符编码出现的Job failed to start解决方法
  3. jsp页面路径问题
  4. js-方法
  5. shell join 参数详细说明
  6. 5个有用的.net profiling工具(转)
  7. 脚本学习python和linux-shell和jQuery(javascript)
  8. Java容器详解
  9. OLE-DB 操作excel 基本
  10. C++ 类的继承、虚拟继承、隐藏、占用空间
  11. mysql编码设置 [http://blog.knowsky.com/254652.htm]
  12. 从零开始学习springboot之springboot搭建
  13. 关于PHP新手学习的一些指导与建议,新手快到我碗里来!
  14. Qt 信号如何自动连接槽函数?
  15. js监听事件
  16. Linux启动顺序、运行级别及开机启动
  17. css 实现背景图片不跟着滚动条滚动而滚动
  18. nat123学习笔记
  19. MySQL之开启远程连接
  20. 浅析PCIe链路LTSSM状态机

热门文章

  1. Jupyter notebook upload无法加载本地ipynb文件
  2. uniapp 小程序自定义组件样式穿透问题
  3. MybatisPlus #{param}和${param}的用法详解
  4. vscode 中前端代码不能通过ctrl+鼠标左键点击跳转(亲测可行)
  5. 【git】3.5 git分支-远程分支
  6. js 动态给table添加、删除行。
  7. jquery获取单选按钮选中的值
  8. vue本地运行项目使用iframe的跨域问题
  9. 如何在Debian10镜像中设置Nginx引擎模块
  10. maven 简易入门笔记