Chrome是可以关闭同源策略的。有时候在开发时候为了方便,开发者需要关闭一下。一些文章记录的方便根本不行,也不知道是什么写的是否亲测过。这边记录一下。方便使用
window步骤:
- a. 新建一个chrome快捷方式,右键“属性”。\
- b. “快捷方式”选项卡里选择“目标”,添加 --args --disable-web-security --user-data-dir
上面方法亲测失败。
亲测方法
1.在c盘新建一个文件夹名为‘MyChromeUserdata’,用于储存数据;
2.创建快捷图标
3.更改属性
目标改为:
"C:\Users\86176\AppData\Local\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files --user-data-dir="C:\MyChromeUserData" --disable-web-security
注意"C:\Users\86176\AppData\Local\Google\Chrome\Application\chrome.exe" 此为本人文件位置。 所以只需要加
--allow-file-access-from-files --user-data-dir="C:\MyChromeUserData" --disable-web-security
原来目标为C:\Users\86176\AppData\Local\Google\Chrome\Application\chrome.exe。 注意需要再英语输入法加"".
更改完毕,用新快捷打开浏览器,如图。同源策略关闭成功
mac步骤:
open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --ignore-certificate-errors --user-data-dir=/Users/${此处完成用户名}/MyChromeDevUserData/
笔者window系统。上述方法并未亲测。姑且记录一下