一、问题:
打开本地html文件时,报错如下
Cross origin requests are only supported for protocol schemes: http, data,chrome-extension, https, chrome-extension-resource.
二、分析:
浏览器为了安全性考虑,默认对跨域访问禁止。
三、解决:
给浏览器传入启动参数(allow-file-access-from-files),允许跨域访问。
Windows下,运行(CMD+R)或建立快捷方式:
"C:UsersxutingtingAppDataLocalGoogleChromeApplicationchrome.exe" --allow-file-access-from-files
参考资料:
四、操作步骤:
1.关闭chrome浏览器
2.cmd+R打开控制台
3.运行如下命令
"C:UsersxutingtingAppDataLocalGoogleChromeApplicationchrome.exe" --allow-file-access-from-files
4.打开浏览器之后打开本地页面