1.写了一个简单的悬浮框以下javascript
test(){ //写入 let suspensionBox= document.createElement("div"); suspensionBox.setAttribute("style","background-color:rgba(0,0,0,0.3);position:absolute;margin-top: 44px;width:100vw;height:30px;border:solid 1px #696969;"); var oneButton = document.createElement("input"); oneButton.setAttribute("type","button"); oneButton.setAttribute("value","x"); oneButton.setAttribute("style","background-color: #A9A9A9;float: right;"); suspensionBox.appendChild(oneButton); var text = document.createElement("input"); text.setAttribute("type","button"); text.setAttribute("value","我是悬浮框**老人 在客厅"); text.setAttribute("style","color:white"); suspensionBox.appendChild(text); document.body.appendChild(suspensionBox); //删除 let that = this; oneButton.onclick=function(){ document.body.removeChild(suspensionBox); } }