Skip to content

Commit 0348850

Browse files
committed
chore(docs): update multi example
1 parent d732597 commit 0348850

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

docs/examples/multi/Flow.vue

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
<script setup>
2-
import { Background } from '@vue-flow/background'
3-
import { Panel, VueFlow, isNode } from '@vue-flow/core'
42
import { ref } from 'vue'
3+
import { Background } from '@vue-flow/background'
4+
import { Panel, VueFlow } from '@vue-flow/core'
55
6-
const elements = ref([
6+
const nodes = ref([
77
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' },
88
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, class: 'light' },
99
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 }, class: 'light' },
1010
{ id: '4', label: 'Node 4', position: { x: 400, y: 200 }, class: 'light' },
11-
{ id: 'e1-2', source: '1', target: '2', animated: true },
11+
])
12+
13+
const edges = ref([
14+
{ id: 'e1-2', source: '1', target: '2' },
1215
{ id: 'e1-3', source: '1', target: '3' },
16+
{ id: 'e3-4', source: '3', target: '4' },
1317
])
1418
1519
function toggleClass() {
16-
return elements.value.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light'))
20+
nodes.value = nodes.value.map((node) => {
21+
return {
22+
...node,
23+
class: node.class === 'light' ? 'dark' : 'light',
24+
}
25+
})
1726
}
1827
1928
function updatePos() {
20-
return elements.value.forEach((el) => {
21-
if (isNode(el)) {
22-
el.position = {
29+
nodes.value = nodes.value.map((node) => {
30+
return {
31+
...node,
32+
position: {
2333
x: Math.random() * 400,
2434
y: Math.random() * 400,
25-
}
35+
},
2636
}
2737
})
2838
}
2939
</script>
3040

3141
<template>
32-
<VueFlow v-model="elements" fit-view-on-init>
42+
<VueFlow :nodes="nodes" :edges="edges" fit-view-on-init>
3343
<Background />
3444

3545
<Panel position="top-right">

0 commit comments

Comments
 (0)