Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用execCommand提示parent找不到 #733

Closed
DerrickTel opened this issue Jul 9, 2024 · 9 comments
Closed

调用execCommand提示parent找不到 #733

DerrickTel opened this issue Jul 9, 2024 · 9 comments

Comments

@DerrickTel
Copy link

DerrickTel commented Jul 9, 2024

我的参数配置如下:

mindMap.current.execCommand(
      'INSERT_NODE',
      [],
      list.map((v) => {
        return {
          data: {
            uid: createUid(),
            text: v.name,
          },
        };
      }),
    );

list如下:

[
    {
        "data": {
            "uid": "5f5ec068-1189-4a10-8d9e-65c559f5d8f6",
            "text": "删除"
        }
    },
    {
        "data": {
            "uid": "79988d5d-fa32-4211-ac08-bb435685570e",
            "text": "测试因子5"
        }
    },
    {
        "data": {
            "uid": "af946951-d9ba-4952-ae51-d4162fcbbfc2",
            "text": "测试因子6"
        }
    }
]
@wanglin2
Copy link
Owner

wanglin2 commented Jul 9, 2024

参数不对,文档看不懂,可以看看教程:https://wanglin2.github.io/mind-map/#/doc/zh/course3

@wanglin2 wanglin2 closed this as completed Jul 9, 2024
@DerrickTel
Copy link
Author

DerrickTel commented Jul 9, 2024

@DerrickTel
Copy link
Author

改成了这样还是不行

mindMap.current.execCommand(
      'INSERT_NODE',
      false,
      [],
      list.map((v) => {
        return {
          data: {
            uid: createUid(),
            text: v.name,
          },
        };
      }),
    );

@wanglin2
Copy link
Owner

wanglin2 commented Jul 9, 2024

第三个参数它也不是数组啊

@DerrickTel
Copy link
Author

插入多个同级节点
插入多个同级节点可以执行INSERT_MULTI_NODE命令:

mindMap.execCommand('INSERT_NODE'. [], nodeList)
nodeList是要插入的同级节点数据的数组,必传。

@DerrickTel
Copy link
Author

源码:

//  插入同级节点
  insertNode(
    openEdit = true,
    appointNodes = [],
    appointData = null,
    appointChildren = []
  )

那我应该传

mindMap.current.execCommand(
      'INSERT_NODE',
      false,
      list.map((v) => {
        return {
          data: {
            uid: createUid(),
            text: v.name,
          },
        };
      }),
    );

这样也不对

@DerrickTel
Copy link
Author

哦我知道了。文档写错了。

插入多个同级节点
插入多个同级节点可以执行INSERT_MULTI_NODE命令:

mindMap.execCommand('INSERT_NODE'. [], nodeList)
nodeList是要插入的同级节点数据的数组,必传。

代码那里的命令错了

@DerrickTel
Copy link
Author

哦我知道了。文档写错了。

插入多个同级节点 插入多个同级节点可以执行INSERT_MULTI_NODE命令:

mindMap.execCommand('INSERT_NODE'. [], nodeList) nodeList是要插入的同级节点数据的数组,必传。

代码那里的命令错了

@wanglin2 有空更新一下

https://wanglin2.github.io/mind-map/#/doc/zh/course3/%E6%8F%92%E5%85%A5%E5%A4%9A%E4%B8%AA%E5%90%8C%E7%BA%A7%E8%8A%82%E7%82%B9

@DerrickTel
Copy link
Author

INSERT_MULTI_NODE

应该都是【INSERT_MULTI_NODE】你在下面的代码写的是【INSERT_NODE】

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants