如何从另一个方法调用方法中的方法?

时间:2017-06-08 09:29:26

标签: javascript

在javascript文件中我有这个:

Work.expenses= function (params)
{
    function deleteExpenses() 
    {
      //here I want to call the loadExpensesList method
    }
}

Work.expensesList= function (params)  
{
    function loadExpensesList() 
    {
     //this is the method I want to call
    }
}

如何在deleteExpenses方法中调用loadExpensesList方法? 谢谢!

1 个答案:

答案 0 :(得分:0)

Work.expenses= function (params)
{
    function deleteExpenses() 
    {
      Work.expensesList('something')();
    }
}

Work.expensesList= function (params)  
{
    function loadExpensesList() 
    {

    }
    return loadExpensesList;
}

你可以这样试试。但通过了解要求可以更好。