@@ -42,7 +42,7 @@ Consider this example, where we want to create a Sidebar that allows us to selec
42
42
<div>
43
43
<Sidebar />
44
44
<div class="wrapper">
45
- <VueFlow v-model="elements " />
45
+ <VueFlow :nodes="nodes" :edges="edges " />
46
46
</div>
47
47
</div>
48
48
</template>
@@ -105,24 +105,28 @@ If you want to strictly control state changes you can disable this behavior by s
105
105
to ` false ` .
106
106
107
107
``` vue
108
- <div style="height: 300px" >
109
- <VueFlow v-model="elements " :apply-default="false" />
110
- </div >
108
+ <template >
109
+ <VueFlow :nodes="nodes" :edges="edges " :apply-default="false" />
110
+ </template >
111
111
```
112
112
113
113
State changes are emitted by the ` onNodesChange ` or ` onEdgesChange ` events, which will provide an array of changes that
114
114
have been triggered.
115
115
To take control of state changes you can implement your own state update handlers or use the state helper functions that
116
116
come with the library to mix it up.
117
117
118
+ ::: info
119
+ Read more about this in the [ controlled flow] ( /guide/controlled-flow ) guide.
120
+ :::
121
+
118
122
## Access State in Options API
119
123
120
124
` useVueFlow ` was designed to be used in the composition API, __ but__ it is still possible to use it in the options API.
121
125
Though it is necessary to pass a unique id for your Vue Flow state instance, otherwise a look-up will fail and Vue Flow
122
126
will create a new state instance
123
127
when mounted.
124
128
125
- ``` vue{4,32}
129
+ ``` vue
126
130
<script>
127
131
import { VueFlow, useVueFlow } from '@vue-flow/core'
128
132
@@ -131,13 +135,14 @@ export default defineComponent({
131
135
components: { VueFlow },
132
136
data() {
133
137
return {
134
- elements : [
138
+ nodes : [
135
139
{
136
140
id: '1',
137
- label: 'Node 1',
138
141
position: { x: 0, y: 0},
142
+ data: { label: 'Node 1' }
139
143
}
140
- ]
144
+ ],
145
+ edges: [],
141
146
}
142
147
},
143
148
methods: {
@@ -153,7 +158,8 @@ export default defineComponent({
153
158
}
154
159
})
155
160
</script>
161
+
156
162
<template>
157
- <VueFlow v-model="elements" id="options-api " @connect="handleConnect" />
163
+ <VueFlow id="options-api" :nodes="nodes" :edges="edges " @connect="handleConnect" />
158
164
</template>
159
165
```
0 commit comments