jackwangblog / foundation

Alert, Toast, Loading, ActionSheet 常用组件封装,没有任何依赖,只适用于移动端。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

foundation

Alert, Toast, Loading, ActionSheet 常用组件封装,没有任何依赖,只适用于移动端。

Alert(title, content, buttons)

  • title: string,必选
  • content: string,可选
  • buttons: array,或者直接为一个function,可选
import {Alert} from 'foundation';
Alert('注册失败', '该邮箱已经被注册,如果有您有任何疑问请咨询客服。');
Alert('注册失败', () => {
    // do something
});
Alert(
    '注册失败', 
    '该邮箱已经被注册,如果有您有任何疑问请咨询客服。', 
    [
        { text: '取消', onClick: () => {} },
        { text: '确定', onClick: () => {} },
    ]
);

Toast(content, time, callback)

  • content: string 必选
  • time: number 显示多少毫秒,可选,默认 1500
  • callback: function 可选
import {Toast} from 'foundation';
Toast.showTop('注册成功');
Toast.showCenter('注册成功', 3000);
Toast.showBottom('注册成功', 3000, () => {
    // do something
});

Loading()

import {Loading} from 'foundation';
Loading.show();

setTimeout(() => {
    Loading.hide();
}, 2000);

ActionSheet(options)

options:

  • title: string,可选
  • options: array,必选
  • destructiveIndex:number 可选
import {ActionSheet} from 'foundation';
ActionSheet({
    options: [
        {
            text: '我再想想',
            onClick: () => {
                // 是应该好好想想
            }
        },
        {
            text: '就这样吧',
            onClick: () => {
                // 借酒消愁去吧
            }
        }
    ],
    destructiveIndex: 1,
    title: '确认要分手吗?'
});

About

Alert, Toast, Loading, ActionSheet 常用组件封装,没有任何依赖,只适用于移动端。

License:MIT License


Languages

Language:JavaScript 72.4%Language:CSS 27.6%