angularjs中關於跨域設置白名單
阿新 • • 發佈:2018-04-17
sid ams pan color tps onf eth .net 註入
在config中註入$sceDelegateProvider服務使用resourceUrlWhitelist([])方法添加白名單
跨域時將method的屬性設置為"jsonp"就可以訪問了
app.config(["$sceDelegateProvider",function($sceDelegateProvider){ $sceDelegateProvider.resourceUrlWhitelist([ <span style="white-space:pre;"> </span>//跨域添加白名單 "self","http://datainfo.duapp.com/**" ]); } ]); $http({ method:"JSONP", url:"http://datainfo.duapp.com/shopdata/getGoods.php", params:{classID:$stateParams.classID} })
參考:https://blog.csdn.net/qq_20343517/article/details/71090229
angularjs中關於跨域設置白名單