AngularJS HTTP拦截器(AngularJS HTTP Interceptors)

编程入门 行业动态 更新时间:2024-10-27 15:24:29
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.

更多推荐

本文发布于:2023-08-06 18:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1454651.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:拦截器   AngularJS   HTTP   Interceptors

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!