weui.js

alert(content, [yes], [options])

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

Kind: global function

Param Type Description
content string 弹窗内容
[yes] function 点击确定按钮的回调
[options] object 配置项
[options.title] string 弹窗的标题
[options.className] string 自定义类名
[options.buttons] array 按钮配置项,详情参考dialog

Example

weui.alert('普通的alert');
weui.alert('带回调的alert', function(){ console.log('ok') });
const 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') }
    }]
});

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