Vue has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
时间: 2023-10-29 16:00:14 浏览: 146
The error message you are seeing indicates a Cross-Origin Resource Sharing (CORS) issue. CORS is a browser security feature that prohibits web pages from making requests to a different domain than the one that served the page.
To resolve this issue, you have a few options:
1. Configure the server: You need to add the appropriate response headers to your server's responses to allow cross-origin requests. Specifically, you need to include the "Access-Control-Allow-Origin" header with the value of the requesting domain.
2. Use a proxy server: If you don't have control over the server's configuration, you can set up a proxy server that forwards requests from your domain to the target server. By doing this, the same-origin policy will be satisfied, and CORS won't be an issue.
3. Use a JSONP request: If the server supports JSONP (JSON with Padding), you can use it as an alternative. JSONP is a technique that allows making cross-origin requests by dynamically adding a ```<script>``` tag to the page.
Choose the appropriate solution based on your specific situation and server setup.
阅读全文