SOURCE

console 命令行工具 X clear

                    
>
console
//foo函数
function* foo() {
    let response1 = yield 1
    console.log('response1')
    // console.log(response1)
    let response2 = yield 2
    console.log('response2')
    console.log(response2)
}

//执行foo函数的代码
let gen = foo()
function getGenPromise(gen) {
    return gen.next().value
}
getGenPromise(gen)
getGenPromise(gen)
// getGenPromise(gen).then((response) => {
//     console.log('response1')
//     console.log(response)
//     return getGenPromise(gen)
// }).then((response) => {
//     console.log('response2')
//     console.log(response)
// })
<html>
<body>

<!-- <script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script> -->
<!-- <script src="https://lib.baomitu.com/vue/2.5.17/vue.js"></script> -->
<!-- <script src="https://unpkg.com/element-ui/lib/index.js"></script> -->
</body>
</html>