首页 > 代码库 > 通过js写一个消息弹框

通过js写一个消息弹框

prompt(data,time) {        let alertForm = document.createElement(‘div‘);        alertForm.id="promptBox";        alertForm.style.position = "fixed";        alertForm.style.right = "4%";        alertForm.style.top = "6%";        alertForm.style.margin = "0 auto";        alertForm.style.width = "300px";        alertForm.style.height = "50px";        alertForm.style.background = "#00bb9c";        alertForm.style.textAlign = "center";        alertForm.style.borderRadius = "5px";        alertForm.style.border = "1px solid #ccc";        alertForm.style.padding= ‘14px 22px‘;        alertForm.style.fontSize= ‘14px‘;        alertForm.style.fontFamily= "微软雅黑";        alertForm.style.fontWeight= ‘normal‘;        alertForm.style.color= ‘#fff‘;        alertForm.style.opacity= ‘.8‘;        alertForm.style.zIndex = "10001";        alertForm.innerHTML = data;        document.getElementsByTagName("body")[0].appendChild(alertForm);        setTimeout(function(){            alertForm.style.display = "none";        },time)    }

 

通过js写一个消息弹框