使用vue代理服務器,請求接口報這樣的錯

錯誤:Failed to load http://zmn_mn_erp.com/index/activity.Activitymanage/sendCode: Req Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.html

解決辦法:ios

在請求時候,,設置了header的content-type屬性axios

this.axios({
        method: 'post',
        url: '/index/activity.Activitymanage/sendCode',
        headers:{
          'Content-Type':'application/x-www-form-urlencoded'
        },
        data:{
          phone:18201458175
        }
}).then(fucntion(res){})

app

this.axios.post('/index/activity.Activitymanage/sendCode',getcode,{
     headers:{
          'Content-Type':'application/x-www-form-urlencoded'
     }
}).then(fucntion(res){})


,但這樣傳值的時候,須要這樣
 post

var getcode = new URLSearchParams();
getcode.append('phone',me.params.leads_phone)
相關文章
相關標籤/搜索