function test0() {
setTimeout(() => {
// test1();
console.log(0);
}, 3000);
}
function test1() {
// test2();
console.log(1);
}, 2000);
function test2() {
console.log(2);
return 2;
}, 1000);
// test0();
function* test() {
var r1 = yield test0();
var r2 = yield test1();
var r3 = yield test2();
console.log(r3);
let g = test();
g.next();
测试结果:
undefined
2
1
0
与期望不符,有点不解,是不是我的测试方法有问题,望解答
Sign in to make a reply
自然萌16675
function test0() {
setTimeout(() => {
// test1();
console.log(0);
}, 3000);
}
function test1() {
setTimeout(() => {
// test2();
console.log(1);
}, 2000);
}
function test2() {
setTimeout(() => {
console.log(2);
return 2;
}, 1000);
}
// test0();
function* test() {
var r1 = yield test0();
var r2 = yield test1();
var r3 = yield test2();
console.log(r3);
}
let g = test();
g.next();
g.next();
g.next();
g.next();
测试结果:
undefined
2
1
0
与期望不符,有点不解,是不是我的测试方法有问题,望解答