uni-app dom操作
电脑版发表于:2020/10/21 10:11
比如引入外部js需要用到的dom操作:
var script = document.createElement('script'); script.src = "http://image.tnblog.net/jquery.min.js"; document.body.appendChild(script);
又或者:
var allpre = document.getElementsByTagName("pre"); for (var i = 0; i < allpre.length; i++) { var classname = allpre[i].className; var substr = classname.match(/:(\S*);toolbar/); if (substr != null) { var needcode = substr[1]; var onepre = document.getElementsByTagName("pre")[i]; var mycode = document.getElementsByTagName("pre")[i].innerHTML; onepre.innerHTML = "<code id='mycode' class='hljs " + needcode + "'>" + mycode + "</code>"; } }