|

楼主 |
发表于 2021-6-2 13:52:54
|
显示全部楼层
解决了
首先不能用textarea,功能限制太死,还是得请div出山
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="js/vue.js" charset="utf-8"></script>
<script src="../js/less.min.js" charset="UTF-8"></script>
<script src="../js/vue.js" charset="UTF-8"></script>
<script src="../js/anime.js" charset="UTF-8"></script>
<title>滚动消息框</title>
<!-- CSS -->
<style>
#logBox{
width: 10rem;
height: 40rem;
resize: none;
background-color: aliceblue;
padding: 0.1875rem;
border: 0.0625rem solid #a0b3d6;
word-wrap: break-word;
overflow-y: auto;
}
.important{
color: #00BFFF;
}
</style>
<!-- JS -->
<script>
window.onload = function(){ }
var printLog = function(text="www",maxLength=20){
var addin = document.createElement("span");
addin.innerHTML = text + "<br />";
addin.className = "normal";
var logBox = document.getElementById("logBox");
logBox.appendChild(addin);
if (logBox.children.length > logBox.maxLength){
logBox.removeChild(logBox.firstElementChild);
}
}
var clearLog = function(){
var logBox = document.getElementById("logBox");
while(logBox.hasChildNodes()){
logBox.removeChild(logBox.lastElementChild);
}
logBox.setAttribute("placeholder","已清空!");
}
</script>
</head>
<body>
<div id="logBox"></div>
<button onclick="printLog()">打印</button>
<button onclick="clearLog()">清空</button>
</body>
</html>
原生JS,不用看上面引入的,一个都没用到,就占个坑 |
|