<BaseEdge />
<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,
});
const { label, labelStyle, markerStart, markerEnd, interactionWidth } = props;
return (
<BaseEdge
path={edgePath}
label={label}
labelStyle={labelStyle}
markerEnd={markerEnd}
markerStart={markerStart}
interactionWidth={interactionWidth}
/>
);
}属性
🌐 Props
| Name | Type | Default |
|---|---|---|
path | stringThe SVG path string that defines the edge. This should look something like
| |
markerStart | stringThe id of the SVG marker to use at the start of the edge. This should be defined in a
| |
markerEnd | stringThe id of the SVG marker to use at the end of the edge. This should be defined in a | |
label | ReactNodeThe label or custom element to render along the edge. This is commonly a text label or some custom controls. | |
labelStyle | CSSPropertiesCustom styles to apply to the label. | |
labelShowBg | boolean | |
labelBgStyle | CSSProperties | |
labelBgPadding | [number, number] | |
labelBgBorderRadius | number | |
interactionWidth | numberThe 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 |
labelX | numberThe x position of edge label | |
labelY | numberThe y position of edge label | |
...props | Omit<SVGAttributes<SVGPathElement>, "d" | "path" | "markerStart" | "markerEnd"> |
注释
🌐 Notes
- 如果你想在
<BaseEdge />组件中使用边缘标记,你可以将markerStart或markerEnd属性传递给你的自定义边缘,再传递给<BaseEdge />组件。你可以通过查看EdgeProps类型来查看传递给自定义边缘的所有属性。