
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
zent-alert
Advanced tools
公告,提供一个醒目的提示信息。
:::demo 基础用法
import { Alert } from 'zent';
ReactDOM.render(
<Alert>公告内容。</Alert>
, mountNode
);
:::
:::demo 公告内容可以是非字符串
import { Alert, Icon } from 'zent';
ReactDOM.render(
<Alert>
<Icon type="error-circle" />
<span>警告:交易过程中的短信通知,将通过营销中心的“消息推送”功能来发送。</span>
<a href="" onClick={e => e.preventDefault()}>立即订购</a>
</Alert>
, mountNode
)
:::
:::demo 三种样式:info, warning 和 danger
import { Alert } from 'zent';
ReactDOM.render(
<div className="zent-alert-example">
<Alert type="info">这个是默认的 info 样式。</Alert>
<Alert type="warning">这个是 warning 样式。</Alert>
<Alert type="danger">这个是 danger 样式。</Alert>
</div>
, mountNode
);
:::
:::demo 公告有两种大小
import { Alert } from 'zent';
ReactDOM.render(
<div className="zent-alert-example">
<Alert>这个时正常尺寸的公告。</Alert>
<Alert size="large">这个是大号的公告。</Alert>
</div>
, mountNode
)
:::
:::demo 支持圆角样式
import { Alert } from 'zent';
ReactDOM.render(
<Alert type="warning" rounded>这个公告是有圆角的。</Alert>
, mountNode
)
:::
:::demo 关闭按钮
import { Alert, Sweetalert } from 'zent';
ReactDOM.render(
<Alert type="info" closable >这个公告可以关闭。</Alert>
, mountNode
)
:::
:::demo 关闭时的回掉
import { Alert, Sweetalert } from 'zent';
ReactDOM.render(
<Alert
type="info"
closable
onClose={() => Sweetalert.alert({ content: '公告关闭了' })}
>
这个公告关闭时有回掉函数。
</Alert>
, mountNode
)
:::
| 参数 | 说明 | 类型 | 默认值 | 备选值 |
|---|---|---|---|---|
| type | 警告提示的样式 | string | 'info' | 'info', 'warning', 'danger' |
| size | alert的大小 | string | 'normal' | 'normal', 'large' |
| rounded | 是否圆角 | bool | false | true, false |
| closable | 默认不可关闭 | bool | false | true, false |
| onClose | 关闭时的回调 | func | noop | |
| className | 自定义额外类名 | string | '' | |
| prefix | 自定义前缀 | string | 'zent' |
FAQs
The npm package zent-alert receives a total of 4 weekly downloads. As such, zent-alert popularity was classified as not popular.
We found that zent-alert demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.