Coder Social home page Coder Social logo

jackwangblog / foundation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xiaoyann/iakit

0.0 2.0 1.0 218 KB

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

License: MIT License

CSS 27.57% JavaScript 72.43%

foundation's Introduction

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: '确认要分手吗?'
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.