0.0.6 • Published 5 years ago

@redbuck/toast v0.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

零依赖toast服务

DEMO

DEMO

安装

npm i @redbuck/toast或者 yarn add @redbuck/toast

引入

html

  <link rel="stylesheet" href="./lib/toast.css">
  <script type="text/javascript" src="./lib/toast.js"></script>

模块

import Toast from '@reabuck/toast'
import '@reabuck/toast/lib/toast.css'

使用

一般用法
  const toast = Toast(ToastOption);

  // toast.d.ts
  type ToastOption = string | managerType

managerType:

属性类型默认值描述
messageString''文字
typeString'text'类型
durationNumber2000延时,0表示永不消失
maskBooleanfalse是否有背景浮层
mountToFunction() => body挂载点
classNameString''自定义根标签class

toast: ToastManager实例.可通过实例方法clear清除自身

别名
  Toast.success(option);
  Toast.loading(option);
  Toast.error(option);

别名即Toast({type: 'name'})的简写方式.

如Toast.success('message')等价于Toast({message: 'message', type: 'success'})

注,loading默认duration为0,不关闭,需要指定时间或手动关闭

methods
  1. Toast.clearAll() 用于清除所有Toast
  2. Toast.clear(seed) 清除指定toast,seed即toast编号,根元素的id即为'toast'+seed
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