gpt4 book ai didi

javascript - enyo.app 卡在创建函数中

转载 作者:行者123 更新时间:2023-12-03 08:47:37 25 4
gpt4 key购买 nike

这是我的代码

当我从我的应用程序中显式调用 getPreloadedAppList 时,例如preLoadedApp.getPreloadedAppList(successCallback1,failCallback1);,我得到了正确的响应:nApps = 12

但是当我在 enyo 类型的 create 函数中执行此操作时,我的程序卡在那里。

enyo.kind({
name:'PreApp',
PreloadedApp : [],
nApps : 0,
Response:function(){
this.onSuccess='';
this.onFailure='';
this.id = 0;
},
create: function(){
this.inherited(arguments);
this.init();
},
getPreloadedAppList: function(getListSuccessCallback,getListFailCallback){
var param = new this.Response();
param.onSuccess = getListSuccessCallback;
param.onFailure = getListFailCallback;
hcap.preloadedApplication.getPreloadedApplicationList(param);
},
launchPreloadedApp: function(launchSuccessCallback,launchFailCallback,id){
var param = new this.Response();
param.id = id;
param.onSuccess = launchSuccessCallback;
param.onFailure = launchFailCallback;
hcap.preloadedApplication.launchPreloadedApplication(param);
},
init : function(){
var suuccessCB = function(param){
this.nApps = param.list.length;
for (var i = 0; i < this.nApps; i++) {
this.PreloadedApp.push(param.list[i]);
}
}
var failureCB = function(param){
alert("Failure " + param.errorMessage);
}
this.getPreloadedAppList.apply(this,[suuccessCB,failureCB]);
}
});

我错过了什么?

最佳答案

我猜你需要像这样绑定(bind) successCB 函数:

init : function(){
var suuccessCB = this.bindSafely(function(param){
this.nApps = param.list.length;
for (var i = 0; i < this.nApps; i++) {
this.PreloadedApp.push(param.list[i]);
}
})
var failureCB = this.bindSafely(function(param){
alert("Failure " + param.errorMessage);
})
this.getPreloadedAppList.apply(this,[suuccessCB,failureCB]);

}

关于javascript - enyo.app 卡在创建函数中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32816935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com