首页 > 代码库 > toast, 警告窗

toast, 警告窗

//浮动提示框 1秒后消失
toast(msg, isError, sec) {
var div = $(‘#toast‘);
div.html(msg);
div.css({visibility: ‘hidden‘});
if (isError) {
div.addClass("error");
} else {
div.removeClass("error");
}
var top = ($(window).height() - div.height()) / 2;
var left = ($(window).width() - (div.width() || 80)) / 2;
var scrollTop = $(document).scrollTop();
var scrollLeft = $(document).scrollLeft();
div.css({position: ‘absolute‘, ‘top‘: top + scrollTop, left: left + scrollLeft, visibility: ‘‘}).show();
//1秒后隐藏
var sec = sec || 3000;
div.delay(sec).hide(0);
},

toast, 警告窗