AngularJS HTTP拦截器(AngularJS HTTP Interceptors)
我想知道AngularJS中的HTTP Interceptors是否会导致性能下降?
我想拦截requests并添加绝对URL:
angular.module('app').config(['$httpProvider', function ($httpProvider) { $httpProvider.interceptors.push(function () { return { request: function (config) { config.url = 'http://localhost:9060/' + config.url; } }; }); }]);I was wondering if HTTP Interceptors in AngularJS cause a performance hit?
I want to intercept requests and prepend the absolute URL:
angular.module('app').config(['$httpProvider', function ($httpProvider) { $httpProvider.interceptors.push(function () { return { request: function (config) { config.url = 'http://localhost:9060/' + config.url; } }; }); }]);最满意答案
除非你在拦截器中做了一些疯狂和耗时的事情,否则在你的应用程序中,与其他任何东西相比,拦截器的实际调用绝对可以忽略不计。
Unless you do something crazy and time-consuming within your interceptor, the actual invocation of the interceptor will be absolutely negligible in your application as compared to anything else.
更多推荐
发布评论