x6画布getSelectedCells获取的数据,处理了之后使用fromJSON渲染到画布上面,只能渲染出来节点,并且无法拖拽,控制台也没有错误 #3993
Unanswered
tingbeauty
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
复制
const selectCells = props.graph.getSelectedCells();
把数据绑定到navigator.clipboard上
navigator.clipboard.writeText(JSON.stringify(selectCells)).then((res) => {
message.success("复制成功");
})
粘贴
navigator.clipboard.readText().then(async (res) => {
let arr = JSON.parse(res);
let oldEdge = [];
let oldCells = [];
arr.forEach((item) => {
if (item.shape == "edge") {
oldEdge.push(item);
} else {
oldCells.push(item);
}
});
for (let i = 0; i < oldCells.length; i++) {
await genTaskCode().then((res) => {
oldCells[i].oldCode = arr[i].code;
oldCells[i].code = res.data + "";
});
}
const cells = props.graph.toJSON();
const arrs = [...cells.cells, ...arr];
props.graph.fromJSON(arrs);
})
Beta Was this translation helpful? Give feedback.
All reactions