H5Dialog是原生js实现toast、alert、confirm弹框,无任何依赖
无
var toast = new aToast()
toast.show({
text: '下载中',
loading: true,
onShow: function () {
console.log('打开了toast1');
setTimeout(function () {
toast.show({
text: '加载完成',
duration: 2000,
onHide: function () {
console.log('关闭了toast2')
}
})
}, 3000)
}
})
var alert = new aAlert()
alert.show({
title: '提示标题',
content: '提示内容',
btnText: '我知道了',
onShow: function () {
console.log('打开了alert')
},
onHide: function () {
console.log('关闭了alert')
}
})
var confirm = new aConfirm()
confirm.show({
title: '提示标题',
content: '提示内容',
btns: [{
callback: function (instance) {
instance.close = false;
console.log('点击了确定按钮,但不会关闭弹窗');
}
}, {
text: '不需要',
callback: function () {
console.log('点击了不需要按钮');
}
}],
onShow: function () {
console.log('打开了confirm')
}
})
(toast|alert|confirm).show()
(toast|alert|confirm).hide()
无