zoukankan      html  css  js  c++  java
  • 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)
        })
      }

    输出

  • 相关阅读:
    day11
    day10
    day9
    day8
    day7
    day6
    day14
    day13
    day12
    day11
  • 原文地址:https://www.cnblogs.com/qq254980080/p/12052518.html
Copyright © 2011-2022 走看看