我知道这可能与某人相似,但我确定,我还没有找到答案,我只是想在变量中调用一个匿名函数,如下所示
me.req.ref['index']['index'] = function() {
var a, mount;
return {
function: function(fout) {
mount = new loading(fout, "flogin");
mount.start("Login granted, redirecting..");
a = setTimeout(function() {
window.location.href = purl+"profile";
}, 1000);
}
}
};
我想这样称呼它。
var ret;
ret = new me.req.ref[refcode][resp];
ret.function(fout);
但它显示出一个错误。
未捕获类型错误:ret不是函数
我在方法中实现这个
loading()
好的,代码在这里。
function loading(e, code) {
var x = 0;
return {
start: function(str) {
var dot, y;
dot = [".","..","...","...."];
y = 0;
e.style.height = "auto";
e.style.maxHeight = "100%";
e.innerHTML = str+dot[y]+" ("+x+")";
me.time.mount[code] = setInterval(function() {
e.innerHTML = str+dot[y]+" ("+x+")";
x++; y++;
if(y>3) {
y = 0;
}
}, 1000);
},
stop: function() {
clearInterval(me.time.mount[code]);
}
}
}
我打电话的方式
正在加载()
就像这样。
mount = new loading(fout, me.time.code["flogin"]);
mount.start("string"); // if i want to start an loading.
mount.stop(); // if i want to shutdown the loading.
有什么解决办法吗?请帮忙。
谢谢你的指正。