LayaAir2.0谷歌浏览器跨域问题解决方式
下载了LayaAir IDE 2.0.2beta版本, 新建LayaAir 2D示例项目, 然后打开 launch.json :
"runtimeExecutable": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
然后点击运行chrome调试, 出现如下错误:
Access to XMLHttpRequest at 'xxxx.json' from origin 'null' has been blocked
by CORS policy: Cross origin requests...
搜索得知是 Mac上的Chrome存在跨域问题, 解决方式为:
- 关闭掉运行着的谷歌浏览器;
- 打开终端;
- 输入命令:
open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/beatzcs(电脑路径)/Documents/MyChromeDevUserData(自定义名称)/
然后谷歌浏览器就被打开, 设置完成.
发现路径文件夹下写入了一些文件:

至此, 重新运行项目,成功运行~
网友评论