错误信息如下:
Access to XMLHttpRequest at 'file:///D:/vscode/axios/data.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
解决办法:
浏览器快捷方式右键属性
然后在目标的最后面输入一个人空格之后加入参数--allow-file-access-from-files
目标里的内容最终长这样:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files
axios跨域问题解决方法(访问本地文件json数据时)
于 2022-03-03 22:18:42 首次发布