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

【BasicTree】 actionList 中的事件触发时,会同时触发节点选中事件 #570

Closed
zuihou opened this issue May 7, 2021 · 2 comments

Comments

@zuihou
Copy link

zuihou commented May 7, 2021

如图和代码:
【BasicTree】 点击 actionList 中的新增或者删除, 会先触发actionList的onClick,然后还会触发一次节点选中事件:handleSelect。 有没有办法能让我点击新增或删除,只触发actionList的onClick??

image

<BasicTree
      title="部门列表"
      toolbar
      checkable
      search
      :actionList="actionList"
      :beforeRightClick="getRightMenuList"
      :clickRowToExpand="true"
      :treeData="treeData"
      :replaceFields="{ key: 'id', title: 'label' }"
      @select="handleSelect"
      ref="treeRef"
    />

      const actionList: ActionItem[] = [
        {
          render: (node) => {
            return h(PlusOutlined, {
              class: 'ml-2',
              onClick: () => {
               console.log('点击了新增')
              },
            });
          },
        },
        {
          render: (node) => {
            return h(DeleteOutlined, {
              class: 'ml-2',
              onClick: () => {
                batchDelete([node.id]);
              },
            });
          },
        },
      ];
@xiaoxian521
Copy link

你可以尝试下面的代码,点击时阻止事件冒泡

    <BasicTree
      title="部门列表"
      toolbar
      checkable
      search
      :actionList="actionList"
      :beforeRightClick="getRightMenuList"
      :clickRowToExpand="true"
      :treeData="treeData"
      :replaceFields="{ key: 'id', title: 'label' }"
      @select="handleSelect"
      ref="treeRef"
    />

      const actionList: ActionItem[] = [
        {
          render: (node) => {
            return h(PlusOutlined, {
              class: 'ml-2',
              onClick: (e) => {
                e.stopPropagation();
                console.log('点击了新增')
              },
            });
          },
        },
        {
          render: (node) => {
            return h(DeleteOutlined, {
              class: 'ml-2',
              onClick: () => {
                batchDelete([node.id]);
              },
            });
          },
        },
      ];

@zuihou
Copy link
Author

zuihou commented May 13, 2021

感谢!

@zuihou zuihou closed this as completed May 13, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants