Skip to content

Commit 67da354

Browse files
committed
chore(docs): cleanup math example
1 parent 51986d7 commit 67da354

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

docs/examples/math/ValueNode.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
<script setup>
2+
import { computed } from 'vue'
23
import { Handle, Position, useVueFlow } from '@vue-flow/core'
34
45
const props = defineProps(['id', 'data'])
56
67
const { updateNodeData } = useVueFlow()
78
8-
function onChange(event) {
9-
const value = Number.parseFloat(event.target.value)
10-
11-
if (!Number.isNaN(value)) {
12-
updateNodeData(props.id, { value })
13-
}
14-
}
9+
const value = computed({
10+
get: () => props.data.value,
11+
set: (value) => updateNodeData(props.id, { value }),
12+
})
1513
</script>
1614

1715
<template>
18-
<label :for="`${id}-input`"> </label>
19-
<input :id="`${id}-input`" :value="data.value" type="number" class="nodrag" @change="onChange" />
16+
<input :id="`${id}-input`" v-model="value" type="number" class="nodrag" />
2017

2118
<Handle type="source" :position="Position.Right" :connectable="false" />
2219
</template>

0 commit comments

Comments
 (0)