axios在请求后端的api时,出现CORS(跨域资源共享),
出现错误
跨域请求Access to XMLHttpRequest at 'http://localhost:8080/api/user/login' from origin 'http://localhosthas been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
需要添加{headers: {'Access-Control-Allow-Origin': '*'}}
但是搞了很长时间发现,只要npm install cors --save