Ant design 消息在 onclick 上不起作用

发布于 2025-01-20 10:31:05 字数 398 浏览 2 评论 0原文

因此,我正在尝试在单击按钮时显示一条消息,但是它的作用是,当页面加载时,它会显示消息框(不应该发生),但它不起作用,但我已将屏幕截图附加到我的代码和观点。

​/I.sstatic.net/i9pxb.png“ alt =”在此处输入图像描述”>

So I am trying to display a message when a button is clicked but what it does is that when the page is loaded it displays message boxes (which should not happen) but it doesn't work on onclick I have attached the screenshots to my code and views.
enter image description here

enter image description here

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独患者 2025-01-27 10:31:05

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

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

或者

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

You need to pass your function to the onClick parameter, not invoke it.

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

or

<Button type="primary" shape="round" onClick={info} />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文