Notification

通知组件,用于显示通知信息。

组件

Notification

<Notification> 组件。

Props

title
PropType: node

通知标题,如无特殊需求,一般无须设置。

amStyle
PropType: string

通知样式,默认为黑色。可选值:

  • 'primary'
  • 'secondary'
  • 'success'
  • 'warning'
  • 'alert'
closeBtn
PropType: bool

是否显示关闭按钮,默认为 true

animated
PropType: bool

打开、关闭是否显示动画效果。

visible
PropType: bool

通知栏是否可见,使用时 visibletrue 打开通知,否则关闭。

static
PropType: bool

是否渲染为静态的通知栏。

onDismiss
PropType: func

点击「关闭」按钮时的处理函数。

示例

  1. import React from 'react';
  2. import {
  3. Container,
  4. Group,
  5. Notification,
  6. Button,
  7. Field,
  8. } from 'amazeui-touch';
  9. const NotificationExample = React.createClass({
  10. getInitialState() {
  11. return {
  12. visible: false,
  13. amStyle: '',
  14. };
  15. },
  16. openNotification() {
  17. this.setState({
  18. visible: true,
  19. amStyle: this.refs.barStyle.getValue()
  20. });
  21. },
  22. closeNotification() {
  23. this.setState({
  24. visible: false
  25. });
  26. },
  27. render() {
  28. return (
  29. <Container {...this.props}>
  30. <Group
  31. header="交互显示"
  32. >
  33. <Field
  34. type="select"
  35. label="选择通知栏颜色"
  36. defaultValue=""
  37. ref="barStyle"
  38. >
  39. <option value="">Default</option>
  40. <option value="primary">Primary</option>
  41. <option value="secondary">Secondary</option>
  42. <option value="success">Success</option>
  43. <option value="warning">Warning</option>
  44. <option value="alert">Alert</option>
  45. </Field>
  46. <Button
  47. onClick={this.openNotification}
  48. disabled={this.state.visible}
  49. amStyle="primary"
  50. >
  51. 显示通知栏
  52. </Button>
  53. <Button
  54. onClick={this.closeNotification}
  55. disabled={!this.state.visible}
  56. amStyle="alert"
  57. >
  58. 关闭通知栏
  59. </Button>
  60. </Group>
  61. <Notification
  62. title="测试标题"
  63. amStyle={this.state.amStyle}
  64. visible={this.state.visible}
  65. animated
  66. onDismiss={this.closeNotification}
  67. >
  68. 这是一个动态显示的通知 :)
  69. </Notification>
  70. <Group
  71. header="静态通知栏样式展示"
  72. >
  73. <Notification visible static>这是一个通知 :)</Notification>
  74. <Notification visible static amStyle="primary">这是一个通知 :)</Notification>
  75. <Notification visible static amStyle="secondary">这是一个通知 :)</Notification>
  76. <Notification visible static amStyle="success">这是一个通知 :)</Notification>
  77. <Notification visible static amStyle="warning">这是一个通知 :)</Notification>
  78. <Notification visible static amStyle="alert">这是一个通知 :)</Notification>
  79. </Group>
  80. </Container>
  81. );
  82. }
  83. });
  84. export default NotificationExample;

DemoCopy

Version: 1.0.0

原文: http://t.amazeui.org/#/docs/notification