alert 警告弹框,功能类似于浏览器自带的 alert 弹框,用于提醒、警告用户简单扼要的信息,只有一个“确认”按钮,点击“确认”按钮后关闭弹框。

ParamTypeDescription
contentstring弹窗内容
[yes]function点击确定按钮的回调
[options]object配置项
[options.title]string弹窗的标题
[options.className]string自定义类名
[options.buttons]array按钮配置项,详情参考dialog
weui.alert('普通的alert');
weui.alert('带回调的alert', function(){ console.log('ok') });
var alertDom = weui.alert('手动关闭的alert', function(){
    return false; // 不关闭弹窗,可用alertDom.hide()来手动关闭
});
weui.alert('自定义标题的alert', { title: '自定义标题' });
weui.alert('带回调的自定义标题的alert', function(){
   console.log('ok')
}, {
   title: '自定义标题'
});
weui.alert('自定义按钮的alert', {
    title: '自定义按钮的alert',
    buttons: [{
        label: 'OK',
        type: 'primary',
        onClick: function(){ console.log('ok') }
    }]
});

// 多次使用
var alert = weui.alert('hello');
alert.hide(function(){
    weui.alert('world');
});

By lxcss

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注