Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 如何修复Vue js中的Axios get和post请求自动更改为选项_Google Chrome_Vue.js_Firefox_Axios - Fatal编程技术网

Google chrome 如何修复Vue js中的Axios get和post请求自动更改为选项

Google chrome 如何修复Vue js中的Axios get和post请求自动更改为选项,google-chrome,vue.js,firefox,axios,Google Chrome,Vue.js,Firefox,Axios,我开发了VUEJS应用程序。我使用axios进行api调用。在chrome浏览器中,所有api调用都正常工作。但是在firefox中,一些api调用不起作用。它的方法更改为options,类型为html this.axios .post("/login", this.userlog) .then(response => { this.successLogin(response); }) .ca

我开发了VUEJS应用程序。我使用axios进行api调用。在chrome浏览器中,所有api调用都正常工作。但是在firefox中,一些api调用不起作用。它的方法更改为options,类型为html

       this.axios
        .post("/login", this.userlog)
        .then(response => {
          this.successLogin(response);
        })
        .catch(error => {
          this.errorLogin(error);
        }); 
这是firefox中的请求头

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
Referer: http://localhost:8080/view-request/150
Origin: http://localhost:8080
Connection: keep-alive```


如果您使用了laravel后端。你应该加上

header("Access-Control-Allow-Headers: Authorization, X-Requested-With,  Content-Type, Accept");
header('Access-Control-Allow-Origin', '*');
此行位于路由文件的顶部。应使用单独的行