官网

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);
};

Vue3 流程图组件库 Vue Flow 简单使用的更多相关文章

  1. vue统计组件库和ui框架

    UI组件 element ★13489 - 饿了么出品的Vue2的web UI工具套件 Vux ★8133 - 基于Vue和WeUI的组件库 iview ★6634 - 基于 Vuejs 的开源 UI ...

  2. Vue3 企业级优雅实战 - 组件库框架 - 1 搭建 pnpm monorepo

    前两篇文章分享了基于 vite3 vue3 的组件库基础工程 vue3-component-library-archetype 和用于快速创建该工程的工具 yyg-cli,但在中大型的企业级项目中,通 ...

  3. Vitepress搭建组件库文档(上)—— 基本配置

    在 vite 出现以前,vuepress 是搭建组件库文档不错的工具,支持以 Markdown 方式编写文档.伴随着 vite 的发展,vitepress 已经到了 1.0.0-alpha.22 版本 ...

  4. Vite+TS带你搭建一个属于自己的Vue3组件库

    theme: nico 前言 随着前端技术的发展,业界涌现出了许多的UI组件库.例如我们熟知的ElementUI,Vant,AntDesign等等.但是作为一个前端开发者,你知道一个UI组件库是如何被 ...

  5. 使用VitePress搭建及部署vue组件库文档

    每个组件库都有它们自己的文档.所以当我们开发完成我们自己的组件库必须也需要一个组件库文档.如果你还不了解如何搭建自己的组件库可以看这里->从零搭建Vue3组件库.看完这篇文章你就会发现原来搭建和 ...

  6. 从0搭建Vue3组件库:button组件

    button组件几乎是每个组件库都有的:其实实现一个button组件是很简单的.本篇文章将带你一步一步的实现一个button组件.如果你想了解完整的组件库搭建,你可以先看使用Vite和TypeScri ...

  7. 从0搭建vue3组件库:Shake抖动组件

    先看下效果 其实就是个抖动效果组件,实现起来也非常简单.之所以做这样一个组件是为了后面写Form表单的时候会用到它做一个规则校验,比如下面一个简单的登录页面,当点击登录会提示用户哪个信息没输入,当然这 ...

  8. 从0搭建vue3组件库: 如何完整搭建一个前端脚手架?

    相信大家在前端开发中都使用过很多前端脚手架,如vue-cli,create-vite,create-vue等:本篇文章将会为大家详细介绍这些前端脚手架是如何实现的,并且从零实现一个create-kit ...

  9. 开箱即用 yyg-cli(脚手架工具):快速创建 vue3 组件库和vue3 全家桶项目

    1 yyg-cli 是什么 yyg-cli 是优雅哥开发的快速创建 vue3 项目的脚手架.在 npm 上发布了两个月,11月1日进行了大升级,发布 1.1.0 版本:支持创建 vue3 全家桶项目和 ...

  10. 从0搭建vue3组件库: Input组件

    本篇文章将为我们的组件库添加一个新成员:Input组件.其中Input组件要实现的功能有: 基础用法 禁用状态 尺寸大小 输入长度 可清空 密码框 带Icon的输入框 文本域 自适应文本高度的文本域 ...

随机推荐

  1. WPF-UI框架MahApps.Metro使用教程

    参考教程:https://www.shuzhiduo.com/A/xl561ZaoJr/ 一,MahApps.Metro安装 1,项目中引用"MahApps.Metro.dll"[ ...

  2. GNSS模块

    1. Location服务注册 第一个注册是在 SystemServer 中将 location 服务注册到 ServiceManager中去:第二个注册是在 SystemServiceRegistr ...

  3. ES 基础操作

    集群 健康值的三种状态 Green:所有索引的所有分片均可用 primary 和 replice 均可用. Yellow 至少有一个 replice不可以用, 但是所有的 primary 正常. Re ...

  4. 【Java学习Day07】标识符

    标识符 Java使用的组成部分的需要名字.类名.变量名以及方法名都被称为标识符 标识符的注意点 所有的标识符都应该以字母(A-Z或者a-z),美元符($).或者下划线(_)开始 首字符之后可以是字母( ...

  5. C++11之线程库

    在 C++11 之前,涉及到多线程问题,都是和平台相关的,比如 Windows 和 Linux 下各有自己的接口,这使得代码的可移植性比较差.C++11 中最重要的特性就是对线程进行支持了,并且可以跨 ...

  6. Dell CS24-SC 服务器详情

    详情介绍: https://www.viziotech.com/servers/58-dell-cs24-sc-dual-xeon-quad-core-l5420-25ghz-16gb-4x146gb ...

  7. error: the option `Z` is only accepted on the nightly compiler

    问题记录 $ cargo expand Checking helo v0.1.0 (/Users/Buzz/Documents/git/rust-lang/hello) error: the opti ...

  8. vi 快捷键/ctags

    vi 配置 syntax enableset nu set relativenumberset hlsearch set autoindentset shiftwidth=4set tabstop=4 ...

  9. [CQOI2006]凸多边形 /【模板】半平面交

    洛谷 题意:逆时针给出\(n(n<=10)\)个凸多边形的顶点坐标,求它们交的面积. 学长博客,计算几何知识全面 半平面交问题详细讲解 其他模板题推荐 [ICPC2020 WF] Domes [ ...

  10. 【vue】Vue-router

    Vue-router 安装 npm install vue-router --save-dev vue-cli中已经选择安装了vue-router,那这里不需要重复安装了 解读route 路径```s ...