0.1.4 • Published 5 years ago

react-custom-toast v0.1.4

Weekly downloads
30
License
MIT
Repository
github
Last release
5 years ago

react-custom-toast

基于 react 的 toast 组件。可以完全的自定义样式。并提供了内置动画与控制方法demo

react-custom-toast demo

Feature

  • 添加测试
  • 上线 demo 网站
  • 更多的内置动画效果

安装

使用 npm 安装

npm install react-custom-toast --save

使用 yarn 安装

yarn add react-custom-toast

使用

添加 ToastContainer 组件至 render

import { ToastContainer } from 'react-custom-toast'

ReactDom.render(<ToastContainer />, document.body)

然后,开始使用 toast

import { Toast } from 'react-custom-toast'

Toast.open('hello,world')

参数

ToastContainer

参数类型默认值描述
componentJSX.FunctionComponentundefinded自定义组件
clickClosebooleanfalse点击 toast 即关闭

Toast

方法

Toast(msg: string, opt: ToastOption) // 打开默认提示

Toast.open(msg: string, opt: ToastOption) // 打开无状态提示

Toast.info(msg: string, opt: ToastOption) // 打开提示

Toast.info(msg: string, opt: ToastOption) // 打开成功提示

Toast.error(msg: string, opt: ToastOption) // 打开错误提示

Toast.warning(msg: string, opt: ToastOption) // 打开警告提示

Toast.remove(id: ToastId) // 移除某个 toast

ToastOption

参数类型默认值描述
idstring|number随机设置 toast id
typestring''提示类型('info' | 'success' | 'error' | 'warning')
placementstringtopLefttoast 方位('topLeft' | 'topRight' | 'topCenter' | 'bottomLeft' | 'bottomRight' | 'bottomCenter')
durationnumber2000提示持续时间
delaynumber0提示出现延时
animateDurationnumber300提示动画时间
animateNamestringslideX提示动画效果('slideX' | 'slideY')

License

MIT

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.8

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago