项目种遇到到跨域,紧急调试,后台又没有时间改的话,可以尝试关闭浏览器的同源策略,可能会出现不安全的情况,请谨慎使用。本次以谷歌浏览器为例
- 出现同源策略的报错

-
关闭同源策略的步骤
1、 右击谷歌浏览器图标,打开文件位置,再新建一个google快捷图标值桌面,命名为“chrome(同源策略)”
右击google图标去文件位置


2、 在c盘新建一个文件夹名为‘MyChromeUserdata’,用于储存数据;

3 、右击刚才新建好的那个快捷图标,点击属性;
目标设为(注意:前面为你的google程序所在位置):"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files --user-data-dir="C:\MyChromeUserData" --disable-web-security
起始位置设为:"C:\Program Files (x86)\Google\Chrome\Application"
完成后点击确定,设置成功,随后通过这个快捷图标打开谷歌浏览器,见证奇迹的时刻到了,如果出现如下图的情况,那么你可以尝试跨域请求了


网友评论