iakit
v2.2.0
The dependency-free mini component library only encapsulates components that are more frequently used, such as alert, toast, loading, actionSheet. A simple mobile project like H5 active pages does not have to introduce a large and complete UI library and framework to use these components.
iakit.alert ![]() | iakit.loading ![]() | iakit.actionSheet ![]() | iakit.toast ![]() |
Installed using yarn/npm, introduced in a modular way
$ yarn add iakit
import * as iakit from 'iakit'
import 'iakit/dist/style.css'
iakit . alert ( '提示' , '测试测试测试测试' )
iakit . loading . show ( )
iakit . actionsheet ( { /* 你的选项 */ } )
iakit . toast . showTop ( '测试测试测试' )You can also directly import files, such as using CDN
< link rel =" stylesheet " href =" https://unpkg.com/[email protected]/dist/style.css " >
< script src =" https://unpkg.com/[email protected]/dist/index.js " > </ script >
< script >
iakit . alert ( '提示' , '测试测试测试测试' )
iakit . loading . show ( )
iakit . actionsheet ( { /* 你的选项 */ } )
iakit . toast . showTop ( '测试测试测试' )
</ script > iakit.alert(title, content, buttons)string , optionalstring , requiredarray | function , optional (button structure: { text: String, onClick: Function }) import * as iakit from 'iakit'
// demo 1.
iakit . alert ( '注册失败' , '该邮箱已经被注册,如果有您有任何疑问请咨询客服。' )
// demo 2.
iakit . alert (
'注册失败' ,
'该邮箱已经被注册,如果有您有任何疑问请咨询客服。' ,
[
{ text : '取消' , onClick : ( ) => { } } ,
{ text : '确定' , onClick : ( ) => { } }
]
) z-index : When there are other elements on the page, and the hierarchy is relatively high, you can use this parameter to adjust the alert level.btnText : The default button copy is "OK", which can be modified through this parameter iakit . alert . config ( {
zIndex : 9999 , // alert 的 z-index
btnText : 'ok' // 默认按钮的文案
} )iakit.toast.showTop(content, time, callback)string Requirednumber displays how many milliseconds, optional, default is 1500function toast The disappearing callback, optional import * as iakit from 'iakit'
// demo 1.
iakit . toast . showTop ( '注册成功' )
// demo 2.
iakit . toast . showCenter ( '注册成功' , 5000 )
// demo 3.
iakit . toast . showBottom ( '注册成功' , ( ) => {
// do something you want
} )iakit.loading.show() import * as iakit from 'iakit'
iakit . loading . show ( )
setTimeout ( ( ) => {
iakit . oading . hide ( )
} , 3000 )iakit.actionsheet(options) string , optionalarray , required (option structure: { text: String, disable: Boolean, onClick: Function })number hazard option, optional import * as iakit from 'iakit'
iakit . actionsheet ( {
options : [
{
text : '我再想想' ,
disable : false ,
onClick : ( i , text ) => { }
} ,
{
text : '去它的(disabled)' ,
disable : true
} ,
{
text : '就这样吧' ,
onClick : ( i , text ) => {
}
}
] ,
destructiveIndex : 2 ,
title : '确认要分手吗?' ,
onClick ( i , text ) {
// 点击了没有指定 onClick 函数的选项时,执行这个函数
} ,
onCancel ( ) {
// 取消了
}
} ) MIT