简单设置让谷歌Chrome浏览器支持跨域方便开发测试

      发布在:前端技术      评论:0 条评论
<div class="Y3BBE" style="font-family: &quot;Google Sans&quot;, Arial, sans-serif; font-size: 16px; line-height: 24px; overflow-wrap: break-word; margin-block: 12px 16px; color: rgb(10, 10, 10); text-wrap-mode: wrap; background-color: rgb(255, 255, 255);">前端开发者想要在谷歌浏览器中进行跨域测试,最简单的方式可以<span style="font-weight: 600;">通过启动参数彻底禁用浏览器的安全策略(CORS 限制)。</span></div><span class="txxDge notranslate" style="visibility: hidden;"><span class="vKEkVd" style="text-wrap-mode: nowrap; position: relative;"><span></span><span class="wiMplc ofC0Ud" style="color: rgb(86, 89, 94); display: inline-block; transform: rotate(135deg);"></span></span></span><img src="https://www.80zx.com/uploadfile/ueditor/image/202602/17706516159f9757.png" title="image" _src="https://www.80zx.com/uploadfile/ueditor/image/202602/17706516159f9757.png" alt="image"><ul class="KsbFXc U6u95 list-paddingleft-2" style="padding: 0px; margin-block: 12px 16px; font-family: &quot;Google Sans&quot;, Arial, sans-serif; font-size: 16px; line-height: 24px; padding-inline-start: 16px; color: rgb(10, 10, 10); text-wrap-mode: wrap; background-color: rgb(255, 255, 255);">​<li style=""><span class="T286Pc" style="overflow-wrap: break-word;"><span class="Yjhzub" style="font-weight: 700;">Windows 用户:</span></span><ol class="IaGLZe VimKh list-paddingleft-2" style="padding: 0px; margin-block: 12px 16px; line-height: 24px; letter-spacing: 0px; padding-inline-start: 20px;"><li style=""><span class="T286Pc" style="overflow-wrap: break-word;">右键点击 Chrome 快捷方式,选择“属性”。</span></li><li style=""><span class="T286Pc" style="overflow-wrap: break-word;">在“目标”输入框末尾添加空格,然后输入以下参数:<br><code class="o8j0Mc" style="font-size: 14px; line-height: 22px; background-color: rgb(240, 242, 245); border-color: rgb(240, 242, 245); border-style: solid; border-width: 0.833333px; border-image: none 100% / 1 / 0 stretch; border-radius: 4px; padding: 2px 4px;">--disable-web-security --user-data-dir="C:\ChromeDev"</code>。</span></li><li style=""><span class="T286Pc" style="overflow-wrap: break-word;">点击“确定”并重启浏览器。</span></li></ol></li><li style=""><span class="T286Pc" style="overflow-wrap: break-word;"><span class="Yjhzub" style="font-weight: 700;">Mac 用户:</span><br>在终端输入以下命令:<br><code class="o8j0Mc" style="font-size: 14px; line-height: 22px; background-color: rgb(240, 242, 245); border-color: rgb(240, 242, 245); border-style: solid; border-width: 0.833333px; border-image: none 100% / 1 / 0 stretch; border-radius: 4px; padding: 2px 4px;">open -n -a /Applications/Google\ Chrome.app --args --disable-web-security --user-data-dir="/tmp/chrome_dev_test"</code>。</span></li></ul>
热门推荐