vue浏览器跨域问题及解决办法
当浏览器报如下错误时,说明请求跨域。
localhost/:1 Failed to load http://www.thenewstep.cn/test/testToken.php: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
跨域的原因:
因为浏览器的同源策略的限制,不是同源的脚本不能操作其他源下面的对象。
什么是同源策略:
同源策略是一种约定,它是浏览器最核心也是最基本的安全功能,如果少了同源策略,则浏