iakit
v2.2.0
A biblioteca mini componente sem dependência encapsula apenas componentes que são usados com mais frequência, como alerta, torrada, carregamento, folha de ação. Um projeto móvel simples como o H5 Active Pages não precisa introduzir uma biblioteca e estrutura de interface do usuário grande e completa para usar esses componentes.
iakit.alert ![]() | Iakit.loading ![]() | Iakit.ActionSheet ![]() | iakit.toast ![]() |
Instalado usando YARN/NPM, introduzido de maneira modular
$ yarn add iakit
import * as iakit from 'iakit'
import 'iakit/dist/style.css'
iakit . alert ( '提示' , '测试测试测试测试' )
iakit . loading . show ( )
iakit . actionsheet ( { /* 你的选项 */ } )
iakit . toast . showTop ( '测试测试测试' )Você também pode importar diretamente arquivos, como usar 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 , opcionalstring , obrigatórioarray | function , opcional (estrutura do botão: {text: string, OnClick: function}) import * as iakit from 'iakit'
// demo 1.
iakit . alert ( '注册失败' , '该邮箱已经被注册,如果有您有任何疑问请咨询客服。' )
// demo 2.
iakit . alert (
'注册失败' ,
'该邮箱已经被注册,如果有您有任何疑问请咨询客服。' ,
[
{ text : '取消' , onClick : ( ) => { } } ,
{ text : '确定' , onClick : ( ) => { } }
]
) z-index : Quando há outros elementos na página e a hierarquia é relativamente alta, você pode usar esse parâmetro para ajustar o nível de alerta.btnText : A cópia do botão padrão é "OK", que pode ser modificada através deste parâmetro iakit . alert . config ( {
zIndex : 9999 , // alert 的 z-index
btnText : 'ok' // 默认按钮的文案
} )iakit.toast.showTop(content, time, callback)string necessárianumber exibe quantos milissegundos, opcionais, o padrão é 1500function brinde o retorno de chamada desaparecendo, opcional 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 , opcionalarray , Necessário (Estrutura da Opção: {Text: String, Desativar: Boolean, OnClick: Function})number , opcional 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