码迷,mamicode.com
首页 > 微信 > 详细

小程序异步问题

时间:2019-08-13 15:33:40      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:ati   this   ica   show   app   The   turn   ade   request   

test: function () {

    let param = {

      Channel: "H5",

      ProductId: this.productId,

      Version: 70100

    };

    console.log(2);

    let url = "xxxxx";

    return new Promise((resolve, reject) => {

      cwx.request({

        url: url,

        data: param,

        header: {

          ‘content-type‘: ‘application/json‘

        },

        method: ‘POST‘,

        success: function (res) {

          console.log(3);

          resolve(res);

        },

        fail: function (ex) { 

          reject(ex);

        }

      })

    });

  },

 

  onShow: function(){

    console.log(1);

    this.test()

    .then((res)=>{

      console.log(4);

    })

    .catch((ex)=>{

      //异常处理

    })

  },

小程序异步问题

标签:ati   this   ica   show   app   The   turn   ade   request   

原文地址:https://www.cnblogs.com/-jianjian/p/11345825.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!