1挑童、Ionic CLI代理服務(wù)器
在項(xiàng)目的根目錄下ionic.project添加proxies信息如下
{
"name": "myapp",
"app_id": "",
"proxies": [
{
"path": "/index",
"proxyUrl": "http://60.173.203.34:9192/artbean/api/api1/home/conlist/index"
}
]
}
$http.get("/index")即可訪問對(duì)應(yīng)內(nèi)容 /index/*對(duì)應(yīng)的接口
$http.get("/index")
.success(function(data){
console.debug("baidu:"+data);
alert(data)
})
.error(function(data){
console.debug("baidu:"+data);
alert(data)
});
可配置網(wǎng)址根目錄涨醋,發(fā)布時(shí)再換回
chrmoe Allow-Control-Allow-Origin: 插件
在應(yīng)用商店搜一下“Allow-Control-Allow-Origin: ”就ok了
參考:http://ionichina.com/topic/54f051698cbbaa7a56a49f98
此方法只適用瀏覽器請(qǐng)求顾患,在打包進(jìn)app時(shí)怎么辦?還是不能正常訪問缠俺,
難道只能通過插件的方式了嗎励饵?