useNodesData
透過此 hook,您可以接收傳入節點 ID 的資料。
<script lang="ts">
import { useNodesData } from '@xyflow/svelte';
const nodeData = useNodesData(['node-id-a', 'node-id-b']);
$: {
// nodeData changes whenever the data of the passed node ids get updated
console.log($nodeData);
}
</script>
簽名
名稱 | 類型 |
---|---|
#參數 |
|
# nodeId | 字串 | 字串[] |
#回傳值 |
|
可讀取<{ id: 字串, type:字串, data: 物件} | { id: 字串, type:字串, data: 物件}[]> 一個可讀取的 store,包含傳入的節點 ID 的 id、type 和 data 物件。 |
筆記
- 請查看計算流程範例,了解如何使用此 hook