Ant 设计消息不适用于 onclick

Ant design message doesnot work on onclick

所以我试图在单击按钮时显示一条消息,但它的作用是在加载页面时显示消息框(这不应该发生),但它在我附加的 onclick 上不起作用我的代码和视图的屏幕截图。

您需要将函数传递给 onClick 参数,而不是调用它。

<Button type="primary" shape="round" onClick={() => info()} />

<Button type="primary" shape="round" onClick={info} />