有谁知道“如何从同一个闪电组件中的另一个函数调用闪电控制器函数?” 谢谢阿鲁娜
({
doInit: function(component, event, helper){
var action = component.get("c.gettemps");
action.setParams({ recordId : component.get("v.recordId") });
action.setCallback(this, function(response){
var parsedJSON= JSON.parse(response.getReturnValue());
var size=component.get("v.limit");
var counter = component.get("v.counter");
component.set("{!v.myObject}",parsedJSON);
var list=[];
for(var i=0; i<size;i++)
{
list.push(parsedJSON[i]);
counter++;
}
component.set("v.end",counter);
component.set("{!v.counter}",counter);
component.set("{!v.paginationList}",list);
});
$A.enqueueAction(action);
},
next:function(component,event,helper)
{
var myObject = component.get("v.myObject");
var size=component.get("v.limit");
var end = component.get("v.end");
var counter = component.get("v.counter");
var list=[];
for(var i=end; i<end+size; i++)
{
if(i<myObject.length)
{
if(i>-1)
{
list.push(myObject[i]);
counter++;
}
}
}
component.set("v.end",counter);
component.set("{!v.counter}",counter);
component.set("{!v.paginationList}",list);
},
previous:function(component,event,helper)
{
var myObject = component.get("v.myObject");
var size=component.get("v.limit");
var end = component.get("v.end");
var counter = component.get("v.counter");
var list=[];
for(var i=end-1; i>end-size-1; i--)
{
if(i>=-1)
{
list.push(myObject[i-1]);
counter--;
}
}
component.set("v.end",counter);
component.set("{!v.counter}",counter);
component.set("{!v.paginationList}",list);
}
})
其实我以前的功能有问题。当我停留在第一页并选择上一个按钮时,我的页面不应更改,但我的代码行为异常。因此,当我已经在第一页时,我想重用我的 doInit 函数以留在当前页面中。请帮助谢谢阿鲁纳