在config中注入$sceDelegateProvider
服務(wù)使用resourceUrlWhitelist([])
方法添加白名單
跨域時(shí)將method的屬性設(shè)置為"jsonp"就可以訪問(wèn)了
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} })
總結(jié)
以上所述是小編給大家介紹的關(guān)于Angularjs中跨域設(shè)置白名單問(wèn)題,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)武林網(wǎng)網(wǎng)站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注