babradu 2021-04-26 16:43 采纳率: 0%
浏览 1870

ant design中notification组件的样式修改

将message和description的文字改成橘色

import { Button, notification, Space } from 'antd';

const openNotificationWithIcon = type => {
  notification[type]({
    message: 'Notification Title',
    description:
      'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
  });
};

ReactDOM.render(
  <Space>
    <Button onClick={() => openNotificationWithIcon('success')}>Success</Button>
    <Button onClick={() => openNotificationWithIcon('info')}>Info</Button>
    <Button onClick={() => openNotificationWithIcon('warning')}>Warning</Button>
    <Button onClick={() => openNotificationWithIcon('error')}>Error</Button>
  </Space>,
  mountNode,
);
  • 写回答

3条回答 默认 最新

  • 崽崽的谷雨 2021-04-26 17:10
    关注

    classname和style都行 

    const openNotification = () => {
      notification.open({
        message: 'Notification Title',
        description:
          'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
        className: 'custom-class',  //类名
        style: {
          width: 600, //样式
        },
      });
    };
    评论

报告相同问题?