笔记
Home
Vuepress
javascript
  • x系列
  • Markdown
  • SCADA
  • 微信小程序
  • weui.js
  • 工作笔记
网址收藏夹
Home
Vuepress
javascript
  • x系列
  • Markdown
  • SCADA
  • 微信小程序
  • weui.js
  • 工作笔记
网址收藏夹
  • 常用网站
  • x系列

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

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

Kind: global function

ParamTypeDescription
contentstring弹窗内容
[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') });
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');
});