var co = require('co');
co(function*() {
this.i = 0;
yield loop1();
})
function* loop1() {
console.log("loop:"+this.i);
this.i++;
yield loop2();
}
function* loop2() {
console.log("loop:"+this.i);
this.i++;
yield loop1();
}
然而这段代码的循环次数永远只有
loop:0
loop:1
loop:2
loop:3
loop:4
loop:5
loop:6
loop:7
loop:8
loop:9
...
loop:3581
loop:3582
loop:3583
loop:3584
loop:3585
loop:3586
loop:3587
难道代码有问题还是本身就是这样的限制那么限制来源是co模块迭代next还是什么...以3587和yield为关键词并未找到相关问题
4 回复