saving custom data #1156
Answered
by
bcakmakoglu
Randommist
asked this question in
Q&A
-
I'm a little confused. I need to make a node that will have a text input field. I also want this to work within the official "Save & Restore" example. I tried saving the entered text in props.data, but it didn't work. What would be the best way to implement this? |
Beta Was this translation helpful? Give feedback.
Answered by
bcakmakoglu
Nov 4, 2023
Replies: 1 comment 6 replies
-
You can't mutate props if that's what you're trying. That's a restriction set by Vue itself. If you want to update the data of a node from inside the node, you could use a vModel of the data obj, something like this const props = defineProps<NodeProps>();
const emits = defineEmits<{ (event: 'update:data', data: { inputText: string } })>();
const vModel = computed({
get: () => props.data,
set: data => emits('update:data', data)
}) <template #node-custom="{ data, ...props }">
<CustomNode v-bind="props" v-model:data="data" />
</template> |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Strange errors, they don't appear in my IDE.
Well, there's another way that possibly even more simple.
Inside of your custom node, you can call
useNode
to get the current node obj from the state and then just mutate thedata
object however you like.For example: