const jQuery = require('jquery'); (function ($) { let close = require("../images/wordClose.png") let loadingImg = require("../images/loading.gif") $.alerModal = function (options) { var dft = { sureBtn:true, quiteBtn:false, width:"400", title:"标题", sureText:"确定", message: '

内容

', time: 1500, type:'modal',//tip,loading callback:function(){ alert(99) } }; var ops = $.extend(dft, options || {}); var html = `

${ops.title}

${ops.message}
取消 ${ops.sureText}
` var tip = `
${ops.message}
` var loading = `
` var box = $("
",{ "class":"divModal", "html":ops.type == 'tip'?tip:ops.type == 'loading'?loading:html }).css({ left:$(".modaltip").width()/2+'px', top:$(".modaltip").height()/2+'px' }) $("body").append(box) if(ops.type == 'tip'){ setTimeout(function(){ box.remove(); }, ops.time); } $(document).on('click',".alertModal .title img, .modalBg",function(){ box.remove(); }) } })(jQuery);