promise

 
  methods: {
    showNum(num, time) {
      return new Promise(function (resolve) {
        function _show() {
          setTimeout(function () {
            console.log(num);
            resolve();
          }, time);
        }
        _show();
      });
    },
    isOpne() {
      var _this = this;
      _this
        .showNum(1, 1000)
        .then(function () {
          return _this.showNum(2, 2000);
        })
        .then(function () {
          return _this.showNum(3, 3000);
        });
    },
  },
posted @ 2022-02-24 14:48    阅读(22)  评论(0)    收藏  举报