Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只是想了解使用触发器 io 为所有 ajax 请求添加授权标头的最佳方法是什么。目前,我在每个请求上手动添加标头。很高兴知道这样的功能是否可用或未记录,如果没有,那么最好的方法是什么。类似于 AFNetworking 的东西,它允许您添加持久标头。
目前没有设置默认值的方法,您可以自己编写一个简单的辅助函数,例如:
var username = "myuser"; var password = "skldjghslg"; function myAjax(options) { options.username = username; options.password = password; forge.request.ajax(options); }
然后,每当您通常使用 forge.request.ajax 时,只需使用 myAjax。