iakit
v2.2.0
無依賴mini 組件庫,只封裝了alert, toast, loading, actionSheet 等使用頻率較高的組件。適用於類似H5 活動頁的簡單移動端項目,不必為了使用這些組件而引入一個大而全的UI 庫和框架。
iakit.alert ![]() | iakit.loading ![]() | iakit.actionSheet ![]() | iakit.toast ![]() |
使用yarn/npm 安裝,以模塊化方式引入
$ yarn add iakit
import * as iakit from 'iakit'
import 'iakit/dist/style.css'
iakit . alert ( '提示' , '测试测试测试测试' )
iakit . loading . show ( )
iakit . actionsheet ( { /* 你的选项 */ } )
iakit . toast . showTop ( '测试测试测试' )也可以直接引入文件,比如使用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 ,可選string ,必選array | function ,可選(button 結構:{ text: String, onClick: Function }) import * as iakit from 'iakit'
// demo 1.
iakit . alert ( '注册失败' , '该邮箱已经被注册,如果有您有任何疑问请咨询客服。' )
// demo 2.
iakit . alert (
'注册失败' ,
'该邮箱已经被注册,如果有您有任何疑问请咨询客服。' ,
[
{ text : '取消' , onClick : ( ) => { } } ,
{ text : '确定' , onClick : ( ) => { } }
]
) z-index :在頁面有其他元素的使用了定位並且層級比較高時可以使用這個參數調整alert 的層級btnText : 默認按鈕的文案是“確定”,可以通過這個參數修改 iakit . alert . config ( {
zIndex : 9999 , // alert 的 z-index
btnText : 'ok' // 默认按钮的文案
} )iakit.toast.showTop(content, time, callback)string必選number顯示多少毫秒,可選,默認1500function toast 消失後的回調,可選 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 ,可選array可以操作的選項,必選(option 結構:{ text: String, disable: Boolean, onClick: Function })number危險選項的index, 可選 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