Skip to Content
参考手册组件

<BaseEdge />

GitHub 上的源代码

¥Source on GitHub

<BaseEdge /> 组件在内部用于所有边缘。它可以在自定义边缘内使用,并为你处理不可见的辅助边缘和边缘标签。

¥The <BaseEdge /> component gets used internally for all the edges. It can be used inside a custom edge and handles the invisible helper edge and the edge label for you.

import { BaseEdge } from '@xyflow/react'; export function CustomEdge({ sourceX, sourceY, targetX, targetY, ...props }) { const [edgePath] = getStraightPath({ sourceX, sourceY, targetX, targetY, }); return <BaseEdge path={edgePath} {...props} />; }

属性

¥Props

NameTypeDefault
pathstring

The SVG path string that defines the edge. This should look something like 'M 0 0 L 100 100' for a simple line. The utility functions like getSimpleBezierEdge can be used to generate this string for you.

markerStartstring

The id of the SVG marker to use at the start of the edge. This should be defined in a <defs> element in a separate SVG document or element.

markerEndstring

The id of the SVG marker to use at the end of the edge. This should be defined in a <defs> element in a separate SVG document or element.

labelReactNode

The label or custom element to render along the edge. This is commonly a text label or some custom controls.

labelStyleCSSProperties

Custom styles to apply to the label.

labelShowBgboolean
labelBgStyleCSSProperties
labelBgPadding[number, number]
labelBgBorderRadiusnumber
interactionWidthnumber

The width of the invisible area around the edge that the user can interact with. This is useful for making the edge easier to click or hover over.

20
labelXnumber

The x position of edge label

labelYnumber

The y position of edge label

...propsOmit<SVGAttributes<SVGPathElement>, "d" | "path" | "markerStart" | "markerEnd">

注释

¥Notes

  • 如果你想将边缘标记与 <BaseEdge /> 组件一起使用,则可以将传递给自定义边缘的 markerStartmarkerEnd 属性传递到 <BaseEdge /> 组件。你可以通过查看 EdgeProps 类型来查看传递给自定义边缘的所有属性。

    ¥If you want to use an edge marker with the <BaseEdge /> component, you can pass the markerStart or markerEnd props passed to your custom edge through to the <BaseEdge /> component. You can see all the props passed to a custom edge by looking at the EdgeProps type.

Last updated on