antd notice提醒框 ---Message

本文介绍如何在React应用中利用Ant Design组件库创建动态的通知提醒框,包括不同类型的提醒(如成功、信息、警告、错误)及其显示位置的定制。通过具体代码示例,展示了如何通过按钮触发各种类型的通知,并设置其在屏幕上的显示位置。

 

import React from 'react'

import { Card, Button, notification } from 'antd'

import './ui.less'

export default class Buttons extends React.Component {

type是传的参数,direction定义方位

openNotification = (type,direction)=>{

if (direction){

notification.config({

placement: direction

})

}

notification[type]({

message:'发工资了',

description:'上个月考勤22天,迟到12天,实发工资250,请笑纳'

});

}

 

render(){

return (

<div>

<Card title="通知提醒框" className="card-wrap">

<Button type="primary" onClick={()=>this.openNotification('success')}>Success</Button>

<Button type="primary" onClick={()=>this.openNotification('info')}>Info</Button>

<Button type="primary" onClick={()=>this.openNotification('warning')}>Warning</Button>

<Button type="primary" onClick={()=>this.openNotification('error')}>Error</Button>

</Card>

<Card title="通知提醒框" className="card-wrap">

<Button type="primary" onClick={() => this.openNotification('success','topLeft')}>Success</Button>

<Button type="primary" onClick={() => this.openNotification('info','topRight')}>Info</Button>

<Button type="primary" onClick={() => this.openNotification('warning','bottomLeft')}>Warning</Button>

<Button type="primary" onClick={() => this.openNotification('error','bottomRight')}>Error</Button>

</Card>

</div>

);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值