我是 vscode 新手。
我的问题可能看起来很愚蠢。
我有 3 个文件:index.html
、index.js
和 index.css
。
我安装了 chrome 调试扩展,但不知道如何运行我的代码
如果我想运行/调试我在 chrome 中收到这个错误
我确定问题出在 launch.json 文件上。在这里:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
我想要的是要启动的index.html
最佳答案
由于您没有运行任何网络服务器以使其在本地主机上查看,因此您不能将 url 设置为 localhost
而是简单地告诉 chrome 从您的工作区打开文件。
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "${workspaceFolder}/index.html", // <-- This should be the path of the index.html file relative to the workspace
"webRoot": "${workspaceFolder}"
}
]
}
关于visual-studio-code - 无法在vscode中运行网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62611349/