如何在 Javascript 中调用函数时直接访问对象的属性而无需引用对象

How is it possible to access property of an Object directly without making reference to an Object while calling a function in Javascript

本文关键字:对象 访问 属性 引用 Javascript 调用 函数      更新时间:2023-09-26

我有这个函数,它从其他文件中引用

define(function() {
    return function service1(){
       function setting1(){
           return{
               settings: {
                   url: '',
                   timeout: 1000,
                   type: 'GET',
                   headers: {'xyz' : null},
                   xhrFields: {
                       isRegistered: false
                   }
                   switch: ON
               }
            };
       }     
        this.calls1 = {
            details: setting1()
        };
    };
}); 

下面的函数调用是从另一个文件进行的。 this.service1.details();上述service1.details()如何运作?

对不起,伙计们,我在团队中有一个白痴TL,他说这是不使用AJAX的基本jQuery,他也浪费了我大量的时间,后来我发现这是可能的,因为内部构建了易于开发的框架。