前言:
现在看官们对“flowchartjs”大约比较关怀,同学们都需要了解一些“flowchartjs”的相关知识。那么小编同时在网摘上网罗了一些对于“flowchartjs””的相关文章,希望小伙伴们能喜欢,同学们快快来学习一下吧!今天给大家分享一款功能超简易的vue.js流程图组件FlowChartVue。
flowchart-vue 一个操作简便的Vue流程图组件。可轻松快速制作演示流程图、项目流程结构图,可自由增删改节点操作。
安装
$ npm i flowchart-vue -S
插件使用
<template> <div id="app"> <button type="button" @click="$refs.chart.add({id: +new Date(), x: 10, y: 10, name: 'New', type: 'operation', approvers: []})">增加</button> <button type="button" @click="$refs.chart.remove()">删除</button> <button type="button" @click="$refs.chart.editCurrent()">编辑</button> <button type="button" @click="$refs.chart.save()">保存</button> <flowchart :nodes="nodes" :connections="connections" @editnode="handleEditNode" @dblclick="handleDblClick" @editconnection="handleEditConnection" @save="handleChartSave" ref="chart"> </flowchart> </div></template><script> import Vue from 'vue'; import FlowChart from 'flowchart-vue'; Vue.use(FlowChart); export default { name: 'App', data: function() { return { nodes: [ // Basic fields {id: 1, x: 140, y: 270, name: 'Start', type: 'start'}, // You can add any generic fields to node, for example: description // It will be passed to @save, @editnode {id: 2, x: 540, y: 270, name: 'End', type: 'end', description: 'I'm here'}, ], connections: [ { source: {id: 1, position: 'right'}, destination: {id: 2, position: 'left'}, id: 1, type: 'pass', }, ], }; }, methods: { handleChartSave(nodes, connections) { // axios.post(url, {nodes, connections}).then(resp => { // this.nodes = resp.data.nodes; // this.connections = resp.data.connections; // }); }, handleEditNode(node) { if (node.id === 2) { console.log(node.description); } }, handleEditConnection(connection) {//...}, handleDblClick(position) { this.$refs.chart.add({ id: +new Date(), x: position.x, y: position.y, name: 'New', type: 'operation', approvers: [], }); }, } };</script>
最后放上示例及仓库地址
# 示例地址 github地址
好了,就介绍到这里。感兴趣的小伙伴可以去尝试下哈!
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。
标签: #flowchartjs