return new Promise的時候,不能帶着.then()方法


app.js

return new Promise的同時帶着.then()方法會出錯

return出去的這個Promise,整體狀態會顯示pending,雖然詳細里狀態顯示resolve,但是沒有resolve的值

調用這個Promise,再調用.then()方法后,回調res的值會出現undefined

test(){
    return new Promise((resolve, reject)=>{
      resolve('resolved.......')
    })
    .then(res=>{
      console.log('.then..........')
    })
  }

job-detail.js

onLoad: function (options) {
    console.log(app.test())
    app.test()
    .then(res=>{
      console.log(res)
    })
  }

輸出


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM