我正在使用Visual代码,并且我已经安装了LiveServer来运行JavaScript代码。但是Javascript代码不在Live中运行,只有HTML代码正在运行并显示
发布于 2020-04-01 02:47:15
VSC的LiveServer扩展的目的是将您的工作区目录公开到localhost:5000中,并以index.html (如果存在)作为切入点。如果您想通过JavaScript执行任何LiveServer,您需要首先在head或body元素中使用脚本标记在head文件中实现它。
// this is my main.js located in scripts catalog
document.getElementById("script").innerHTML = 'Hello World'<script src="scripts/main.js"></script>
<h1 id="script"></h1>
https://stackoverflow.com/questions/60962585
复制相似问题