首页 > 解决方案 > Ant Design React 中的回调按钮单击事件

问题描述

我正在做一个使用 AntDesign 的项目。布局有一个默认的标题样式,带有在道具中设置的图标:

const Header = () => {
  const headerProps = {
    title: "VIEWER",
    iconsBefore: [
      { icon: { set: "antd", type: "Layers" } },
      { icon: { set: "antd", type: "close" } },
    ],
    iconsAfter: [
      { icon: { set: "antd", type: "Levels" } },
      { icon: { set: "antd", type: "share-alt" } },
    ],
  };

  return (
    <Layout>
// Props are passed into the header bar here
      <Layout.Header {....headerProps}>
        <Button type={`close`} closeFunction={closeFunction} />
      </Layout.Header>
    </Layout>
  );
};

export default Topbar;

这是我以前没有使用过的模式,可能不正确,所以我对这个模式有疑问。如何在 props 中调用指定图标的 onClick 事件。

标签: reactjs

解决方案


推荐阅读