后端代码如下
func main() {
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"*"},
AllowHeaders: []string{"Origin", "Access-Control-Allow-Origin"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
}))
beego.Run()
}
前端代码如下
methods:{
register(){
const data={
username:`${this.username}`,
password:`${this.password}`
}
service
.post('/register', data)
.then((response) => {
console.log(response.data)
})
.catch((error) => {
console.error(error);
});
}
问题出错:
标签:username,beego,string,错误,error,CORS,data,response,跨域 From: https://blog.51cto.com/u_16336880/8602073