Skip to content

turboAdapter.js Cannot destructure property 'x' of 'properties' as it is undefined. #4

@caspianchu

Description

@caspianchu

Uncaught (in promise) TypeError: Cannot destructure property 'x' of 'properties' as it is undefined.
at convertFlowElementToNode (turboAdapter.js?t=1693904724052:157:5)
at turboAdapter.js?t=1693904724052:194:20
at Array.forEach ()
at toLogicflowData (turboAdapter.js?t=1693904724052:189:35)
at t2.adapterIn (turboAdapter.js?t=1693904724052:214:15)
at t2.value (logic-flow.js:15:481557)
at Proxy.mounted (FlowChart.vue:15:1)

// 将Turbo元素数据转换为LogicFlow中的Node数据
function convertFlowElementToNode(element) {
const { properties, key, type, bounds } = element;
let {
x, y, text,
} = properties;
if (x === undefined) {
const [{ x: x1, y: y1 }, { x: x2, y: y2 }] = bounds;
x = (x1 + x2) / 2
y = (y1 + y2) / 2
}
const node = {
id: key,
type: TurboTypeMap[type],
x,
y,
text,
properties: {},
};
// 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
const excludeProperties = ['x', 'y', 'text'];
Object.keys(element.properties).forEach(property => {
if (excludeProperties.indexOf(property) === -1) {
node.properties[property] = element.properties[property];
}
});
return node;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions