[LayaAir3]Laya3.0.13 HTTP请求跨域,如何解决
我的ts是这么写的。请求跨域怎么解决。
hr: Laya.HttpRequest;
http(): void {
//请求
this.hr = new Laya.HttpRequest();
this.hr.once(Laya.Event.PROGRESS, this, this.onHttpRequestProgress);
this.hr.once(Laya.Event.COMPLETE, this, this.onHttpRequestComplete);
this.hr.once(Laya.Event.ERROR, this, this.onHttpRequestError);
this.hr.send('http://localhost:8899/data', null, 'post', 'json',["Content-Type", "application/json"]);
}
private onHttpRequestError(e: any = null): void {
console.log(e);
}
private onHttpRequestProgress(e: any = null): void {
console.log(e)
}
private onHttpRequestComplete(e: any = null): void {
//this.logger.text += "收到数据:" + this.hr.data;
console.log("收到数据");
console.log(this.hr.data);
}
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
layabox
赞同来自: