Material UI 中 message.error() [antd] 的替代组件是什么?
我是 Material UI(Web)的新手,但我已经使用过 and 。我需要显示类似 message.error(antd popup) 的内容,无需将其放入渲染部分并将其作为简单函数调用...我如何在 Material UI 中执行相同操作?
编辑:
我尝试使用组件,但我们必须保持消息显示和显示的状态。每次消息更改时都会渲染警报...我需要一种将警报作为函数调用的方法(例如alert.error({message: ''})或MUI中可以执行此操作的任何其他组件)
在antd中我们可以这样做
// THIS IS TO DISPLAY A POPUP like window. Alert in antd
message.error({message: err||"No network "})
},[err])```
I am new to material UI (web), but I have used and. I need to show something like message.error(antd popup) which I can do without putting it in the render part and call it as a simple function... How do I do the same in Material UI?
Edit:
I tried using component, but we have to maintain a state for the message to be displayed & render the Alert everytime the message changes... I need a way to call Alert as a function (e.g. alert.error({message: ''}) or any other component in MUI which can do it)
In antd we can do
// THIS IS TO DISPLAY A POPUP like window. Alert in antd
message.error({message: err||"No network "})
},[err])```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能想要使用
notistack
。它遵循材料设计并且非常易于使用。You might want to use
notistack
. It follows material design and really easy to use.您可以使用状态来显示/隐藏警报,如以下示例
Demo.js
屏幕截图所示:
You can use state to show/hide the alert as shown in the following example
Demo.js
Screenshot: