toast

A toast plugin

Usage

new Toast('言宜慢,心宜善。');

new Toast('言宜慢,心宜善。', { type: 'smile', lock: true });

function handler(){
  console.log(
    '提示类型:', this.type,
    '>>>', '触发事件:', arguments[0],
    '>>>', '回调参数:', arguments[1]
  );
}

Toast.loading('正在加载数据...', { lock: true }).on('hide', function (){
  Toast.success('言宜慢,心宜善。')
    .on('show', handler)
    .on('hide', handler);
}).on('lock', handler).on('unlock', handler);

API

new Toast(message, options) constructor

message String 消息文本
options Object 配置提示框参数

attribute & method attribute & method

id attribute 提示框身份标识 readonly
locked attribute 提示框锁定状态 readonly
visibility attribute 提示框可见状态 readonly
type attribute 提示框类型 readonly
show method 显示提示框并触发 show 事件,参数可选
hidemethod 隐藏提示框并触发 hide 事件,参数可选
lockmethod 显示遮罩层并触发 lock 事件,参数可选
unlock method 隐藏遮罩层并触发 unlock 事件,参数可选
onmethod 绑定事件监听
off method 移除事件监听
emit method 触发事件回调

static method method

Toast.querymethod 根据身份标识获取提示框实例
Toast.success method 成功提示框
Toast.error method 错误提示框
Toast.info method 消息提示框
Toast.ask method 询问提示框
Toast.warn method 警告提示框
Toast.loading method 加载提示框

Demo

在线实例