Angularjs中怎么设置跨域白名单
Angularjs中怎么设置跨域白名单,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
在config中注入$sceDelegateProvider
服务使用resourceUrlWhitelist([])
方法添加白名单
跨域时将method的属性设置为"jsonp"就可以访问了
app.config(["$sceDelegateProvider",function($sceDelegateProvider){ $sceDelegateProvider.resourceUrlWhitelist([ <span > </span>//跨域添加白名单 "self", "http://datainfo.duapp.com/**" ]); } ]); $http({ method:"JSONP", url:"http://datainfo.duapp.com/shopdata/getGoods.php", params:{classID:$stateParams.classID} })
看完上述内容,你们掌握Angularjs中怎么设置跨域白名单的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!