我正在尝试动态加载脚本,但无法正常工作,我在这里做错什么了?
<script>
function loadXMLDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo").innerHTML = this.responseText; } }; xhttp.open("GET","haromd.js",true); xhttp.send(); };
loadXMLDoc();
</script>
<script type="module" id="demo"></script>
外部脚本文件仅包含进入模块类型脚本标记的脚本。 如果没有xhr的脚本标记中包含相同的脚本,则该脚本可以正常运行/运行,没有任何问题。