chore(docs): cleanup math example
This commit is contained in:
@@ -1,22 +1,19 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
import { Handle, Position, useVueFlow } from '@vue-flow/core'
|
import { Handle, Position, useVueFlow } from '@vue-flow/core'
|
||||||
|
|
||||||
const props = defineProps(['id', 'data'])
|
const props = defineProps(['id', 'data'])
|
||||||
|
|
||||||
const { updateNodeData } = useVueFlow()
|
const { updateNodeData } = useVueFlow()
|
||||||
|
|
||||||
function onChange(event) {
|
const value = computed({
|
||||||
const value = Number.parseFloat(event.target.value)
|
get: () => props.data.value,
|
||||||
|
set: (value) => updateNodeData(props.id, { value }),
|
||||||
if (!Number.isNaN(value)) {
|
})
|
||||||
updateNodeData(props.id, { value })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<label :for="`${id}-input`"> </label>
|
<input :id="`${id}-input`" v-model="value" type="number" class="nodrag" />
|
||||||
<input :id="`${id}-input`" :value="data.value" type="number" class="nodrag" @change="onChange" />
|
|
||||||
|
|
||||||
<Handle type="source" :position="Position.Right" :connectable="false" />
|
<Handle type="source" :position="Position.Right" :connectable="false" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user