Vscode+Chrome调试直接读取本地文件解决方案

最近学WebGL需要读取本地图片,研究了一下Debbuger for chrome的拓展,发现可以传递执行参数

"runtimeArgs": [

" --disable-web-security"

]

来允许读取本地文件,以下是Json配置文件

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "谷歌浏览器", //运行html文件,用谷歌浏览器打开
            "type": "chrome",
            "request": "launch",
            "url": "${file}",
            "sourceMaps": true,
            "webRoot": "${workspaceRoot}",
            "runtimeArgs": [
                " --disable-web-security"
            ],
        },
        {
            "name": "nodeLauch", //单独调试js,即可以直接运行js
            "type": "node",
            "request": "launch",
            "program": "${file}", //这个配置成你要调试的文件、${file}当前打开的文件
            "stopOnEntry": false,
            "args": [],
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development"
            },
            "console": "internalConsole",
            "preLaunchTask": "",
            "sourceMaps": false,
            "outDir": null
        }
    ]
}

 

你可能感兴趣的:(Vscode+Chrome调试直接读取本地文件解决方案)