4.22.3 • Published 5 months ago

@uiw/react-message v4.22.3

Weekly downloads
311
License
MIT
Repository
github
Last release
5 months ago

Message 警告提示

Buy me a coffee Open in unpkg NPM Downloads npm version

警告提示,用于页面中展示重要的提示信息。

import { Message } from 'uiw';
// or
import Message from '@uiw/react-message';

基础用法

import React from 'react';
import { Message, Divider } from 'uiw';

class Demo extends React.Component {
  render() {
    return (
      <div>
        <Message type="success" title="成功提示标题" description="这里是成功提示详情描述。" />
        <Message
          type="warning"
          title={<div>警告提示标题</div>}
          description="这里是警告提示详情描述。"
        />
        <Message type="info" title="说明提示标题" description="这里是说明提示详情描述。" />
        <Message type="error" title="错误提示标题" description="这里是错误提示详情描述。" />

        <Divider />
        <Message type="success" title="成功提示标题" />
        <Message type="warning" title="警告提示标题" />
        <Message type="info" title="说明提示标题" />
        <Message type="error" title="错误提示标题" />
      </div>
    )
  }
}
export default Demo;

显示图标

import React from 'react';
import { Message, Divider } from 'uiw';

export default function Demo() {
  return (
    <div>
      <Message showIcon type="success" title="成功提示标题" />
      <Message showIcon type="warning" title="警告提示标题" />
      <Message showIcon type="info" title="说明提示标题" />
      <Message showIcon type="error" title="错误提示标题" />
      <Divider />
      <Message showIcon type="success" description="这里是成功提示详情描述。" />
      <Message showIcon type="warning" description="这里是警告提示详情描述。这里并没有设置 title,只设置 description 同时设置显示图标。" />
      <Message showIcon type="info" description="这里是说明提示详情描述。" />
      <Message showIcon type="error" description="这里是错误提示详情描述。" />
      <Divider />
      <Message showIcon type="success" title="成功提示标题" description="这里是成功提示详情描述。" />
      <Message
        showIcon
        type="warning"
        title="警告提示标题"
      >
        这里是警告提示详情描述。
      </Message>
      <Message showIcon type="info" title="说明提示标题" description="这里是说明提示详情描述。" />
      <Message showIcon type="error" title="错误提示标题" description="这里是错误提示详情描述。" />
    </div>
  )
}

自定义图标

import React from 'react';
import { Message, Divider } from 'uiw';

const chat = ( <svg width="20" height="20" viewBox="0 0 20 20"> <path d="M19 0H7c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h5.59l3.71 3.71c.17.18.42.29.7.29.55 0 1-.45 1-1v-3h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 13c-1.1 0-2-.9-2-2V4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h1v3a1.003 1.003 0 0 0 1.71.71L7.41 16H13c.55 0 1-.45 1-1v-.17L12.17 13H7z" fillRule="evenodd" /> </svg> );
const closed = <svg viewBox="0 0 16 16" width="16" height="16"> <path fillRule="evenodd" d="M7 10h2v2H7v-2zm2-6H7v5h2V4zm1.5 1.5l-1 1L12 9l4-4.5-1-1L12 7l-1.5-1.5zM8 13.7A5.71 5.71 0 0 1 2.3 8c0-3.14 2.56-5.7 5.7-5.7 1.83 0 3.45.88 4.5 2.2l.92-.92A6.947 6.947 0 0 0 8 1C4.14 1 1 4.14 1 8s3.14 7 7 7 7-3.14 7-7l-1.52 1.52c-.66 2.41-2.86 4.19-5.48 4.19v-.01z" /> </svg>;
class Demo extends React.Component {
  render() {
    return (
      <div>
        <Message showIcon icon="apple" type="error" title="自定义图标" description="这里自定义Icon组件图标。" />
        <Message showIcon icon={chat} type="info" title="自定义图标" description="这里自定义 SVG 图标。" />
        <Message showIcon icon={closed} type="success" title="自定义图标" description="这里自定义 SVG 图标。" />
        <Divider />
        <Message showIcon icon={chat} type="success" title="成功提示标题,自定义图标。" />
        <Message showIcon icon={closed} type="warning" title="警告提示标题,自定义图标。" />
        <Message showIcon icon="apple" type="info" title="说明提示标题,自定义图标。" />
        <Message showIcon icon="file-jpg" type="error" title="错误提示标题,自定义图标。" />
      </div>
    )
  }
}
export default Demo;

关闭按钮

import React from 'react';
import { Message, Divider } from 'uiw';

class Demo extends React.Component {
  render() {
    return (
      <div>
        <Message
          showIcon
          isCloseButtonShown
          type="success"
          title="自定义图标"
          description="这里设置参数 isCloseButtonShown 显示关闭按钮。这里设置 title 和 description 同时设置显示图标。"
        />
        <Divider />
        <Message showIcon isCloseButtonShown type="info" title="说明提示标题,自定义图标。" />
        <Message isCloseButtonShown type="error" title="错误提示标题,自定义图标。" />
      </div>
    )
  }
}
export default Demo;

Props

参数说明类型默认值
type指定警告提示的样式Enum{success, warning, info, error}-
title警告提示标题String/ReactNode-
description警告提示描述详情String/ReactNode-
rounded是否显示圆角Boolean-
showIcon设定显示图标Boolean-
isCloseButtonShown显示关闭按钮Boolean-
icon自定义图标,设置 showIcon=true 才会起作用。String/ReactNode-
onClose点击默认关闭按钮时触发的回调函数Function-
4.22.0

7 months ago

4.22.1

6 months ago

4.22.2

6 months ago

4.22.3

5 months ago

4.21.26

1 year ago

4.21.25

1 year ago

4.21.28

12 months ago

4.21.27

1 year ago

5.0.0-bate.2.1

1 year ago

5.0.0-bate.2.0

1 year ago

4.21.24

1 year ago

5.0.0-bate-19

1 year ago

4.21.22

1 year ago

4.21.21

1 year ago

4.21.23

1 year ago

5.0.0-bate-18

1 year ago

5.0.0-bate-14

1 year ago

5.0.0-bate-17

1 year ago

5.0.0-bate-10

1 year ago

5.0.0-bate-11

1 year ago

5.0.0-bate-12

1 year ago

5.0.0-bate-9

1 year ago

5.0.0-bate-7

1 year ago

5.0.0-bate-8

1 year ago

5.0.0-bate-6

1 year ago

4.21.20

1 year ago

4.21.19

2 years ago

4.21.18

2 years ago

4.21.15

2 years ago

4.21.17

2 years ago

4.21.16

2 years ago

5.0.0-bate-5

2 years ago

5.0.0-bate-3

2 years ago

5.0.0-bate-4

2 years ago

5.0.0-bate-1

2 years ago

5.0.0-bate-2

2 years ago

5.0.0-bate-0

2 years ago

4.21.13

2 years ago

4.21.14

2 years ago

4.21.11

2 years ago

4.21.12

2 years ago

4.21.10

2 years ago

4.21.1

2 years ago

4.21.2

2 years ago

4.21.3

2 years ago

4.21.4

2 years ago

4.21.0

2 years ago

4.20.0

2 years ago

4.21.9

2 years ago

4.21.5

2 years ago

4.21.6

2 years ago

4.21.7

2 years ago

4.21.8

2 years ago

4.18.1

2 years ago

4.18.0

2 years ago

4.17.0

2 years ago

4.16.0

2 years ago

4.16.1

2 years ago

4.16.2

2 years ago

4.19.0

2 years ago

4.15.1

2 years ago

4.14.1

2 years ago

4.14.2

2 years ago

4.14.0

2 years ago

4.13.7

2 years ago

4.13.8

2 years ago

4.13.9

2 years ago

4.13.11

2 years ago

4.13.12

2 years ago

4.13.10

2 years ago

4.15.0

2 years ago

4.10.5

2 years ago

4.10.6

2 years ago

4.10.7

2 years ago

4.9.9

2 years ago

4.10.1

2 years ago

4.10.2

2 years ago

4.10.3

2 years ago

4.10.4

2 years ago

4.10.0

2 years ago

4.13.6

2 years ago

4.13.2

2 years ago

4.13.3

2 years ago

4.13.4

2 years ago

4.13.5

2 years ago

4.13.0

2 years ago

4.13.1

2 years ago

4.12.0

2 years ago

4.12.1

2 years ago

4.12.2

2 years ago

4.11.4

2 years ago

4.11.5

2 years ago

4.11.6

2 years ago

4.9.11

2 years ago

4.9.10

2 years ago

4.11.0

2 years ago

4.11.1

2 years ago

4.11.2

2 years ago

4.11.3

2 years ago

4.9.7

3 years ago

4.9.6

3 years ago

4.9.4

3 years ago

4.9.3

3 years ago

4.9.2

3 years ago

4.9.1

3 years ago

4.9.0

3 years ago

4.8.9

3 years ago

4.8.8

3 years ago

4.7.16

3 years ago

4.8.5

3 years ago

4.8.4

3 years ago

4.8.7

3 years ago

4.8.6

3 years ago

4.8.1

3 years ago

4.8.0

3 years ago

4.8.3

3 years ago

4.8.2

3 years ago

4.7.13

3 years ago

4.7.14

3 years ago

4.7.15

3 years ago

4.7.12

3 years ago

4.7.10

3 years ago

4.7.11

3 years ago

4.7.9

3 years ago

4.7.8

3 years ago

4.7.6

3 years ago

4.7.7

3 years ago

4.7.5

3 years ago

4.7.4

3 years ago

4.7.3

3 years ago

4.7.2

3 years ago

4.7.0

3 years ago

4.6.19

3 years ago

4.6.15

3 years ago

4.6.16

3 years ago

4.6.17

3 years ago

4.6.18

3 years ago

4.6.14

4 years ago

4.6.13

4 years ago

4.6.11

4 years ago

4.6.12

4 years ago

4.6.10

4 years ago

4.6.9

4 years ago

4.6.8

4 years ago

4.6.7

4 years ago

4.6.6

4 years ago

4.6.3

4 years ago

4.6.4

4 years ago

4.6.2

4 years ago

4.6.1

4 years ago

4.6.0

4 years ago

4.5.0

4 years ago

4.4.1

4 years ago

4.4.0

4 years ago

4.3.1

4 years ago

4.2.3

4 years ago

4.2.5

4 years ago

4.3.0

4 years ago

4.2.14

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

4.0.0-alpha.7

4 years ago

4.0.0-alpha.8

4 years ago

4.0.0-alpha.6

4 years ago

4.0.0-alpha.3

4 years ago

4.0.0-alpha.2

4 years ago

4.0.0-alpha.1

4 years ago

4.0.0-alpha.0

4 years ago