收藏
回答

为什么云函数入口执行不了setTimeout

// 云函数入口函数

exports.main = async (event, context) => {

console.log('Start--->A');


setTimeout(function () {

console.log('Time out');

}, 100);


console.log('Start--->End');

}


最后一次编辑于  2018-11-20
回答关注问题邀请回答
收藏

2 个回答

  • 2018-11-21

    谢谢你,大神~~~

    2018-11-21
    有用
    回复
  • 半寸灰
    半寸灰
    2018-11-21

    写法有误 setTimeout是异步的

    你需要改成同步的。  Promise



    await  new Promise(function (resolve, reject) {

        setTimeout(function () {

          console.log("Time out")

          resolve({

            data: "很好" 

          })

        }, 100)



    2018-11-21
    有用
    回复
登录 后发表内容