Node<NodeData, NodeType>
Node
型別代表 Svelte Flow 需要知道的關於特定節點的所有資訊。其中許多屬性可以由 Svelte Flow 或您來操作,但某些屬性(例如 width
和 height
)應視為唯讀。
export type Node<
NodeData extends Record<string, unknown>,
NodeType extends string,
> = {
id: string;
position: XYPosition;
data: NodeData;
type?: NodeType;
sourcePosition?: Position;
targetPosition?: Position;
hidden?: boolean;
selected?: boolean;
dragging?: boolean;
draggable?: boolean;
selectable?: boolean;
connectable?: boolean;
resizing?: boolean;
deletable?: boolean;
dragHandle?: string;
width?: number;
height?: number;
parentId?: string;
zIndex?: number;
extent?: 'parent' | CoordinateExtent;
ariaLabel?: string;
origin?: NodeOrigin;
style?: string;
class?: string;
measured?: {
width?: number;
height?: number;
};
};
欄位
名稱 | 型別 |
---|---|
# id | string |
# position | XYPosition |
# data | T |
# type? | U |
# sourcePosition? | Position |
# targetPosition? | Position |
# hidden? | boolean |
# selected? | boolean |
# dragging? | boolean |
# draggable? | boolean |
# selectable? | boolean |
# connectable? | boolean |
# resizing? | boolean |
# deletable? | boolean |
# dragHandle? | string |
# width? | number | null |
# height? | number | null |
# parentId? | string |
# zIndex? | number |
# extent? | "parent" | CoordinateExtent |
# expandParent? | boolean |
# ariaLabel? | string |
# origin? | NodeOrigin |
# style? | string |
# class? | string |
注意事項
- 您不應嘗試直接設定節點的
measured.width
或measured.height
。它們是由 Svelte Flow 內部測量,並在視窗中渲染節點時使用。若要控制節點的大小,您應該使用width
和height
屬性。