使用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)
相关文章
相关标签/搜索