fix: use local refs for nodes/edges, only useVueFlow for events and fitView
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { watch, nextTick } from 'vue'
|
import { ref, watch, nextTick } from 'vue'
|
||||||
import { VueFlow, useVueFlow } from '@vue-flow/core'
|
import { VueFlow, useVueFlow } from '@vue-flow/core'
|
||||||
import { Background } from '@vue-flow/background'
|
import { Background } from '@vue-flow/background'
|
||||||
import { Controls } from '@vue-flow/controls'
|
import { Controls } from '@vue-flow/controls'
|
||||||
@@ -20,7 +20,9 @@ const emit = defineEmits<{
|
|||||||
addEdge: [source: string, target: string]
|
addEdge: [source: string, target: string]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { nodes, edges, onNodeClick, onConnect, fitView } = useVueFlow()
|
const nodes = ref<any[]>([])
|
||||||
|
const edges = ref<any[]>([])
|
||||||
|
const { onNodeClick, onConnect, fitView } = useVueFlow()
|
||||||
|
|
||||||
function makeNodes() {
|
function makeNodes() {
|
||||||
return props.sceneNodes.map((n, i) => ({
|
return props.sceneNodes.map((n, i) => ({
|
||||||
@@ -99,6 +101,8 @@ onConnect((conn: Connection) => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="scene-graph">
|
<div class="scene-graph">
|
||||||
<VueFlow
|
<VueFlow
|
||||||
|
:nodes="nodes"
|
||||||
|
:edges="edges"
|
||||||
:min-zoom="0.2"
|
:min-zoom="0.2"
|
||||||
:max-zoom="2"
|
:max-zoom="2"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user