黄子涵

查落补缺——.then()方法有什么作用?

问题

如题所示,源代码如下:

fetchCategory() {
      fetchCategory()
        .then((res) => {
          this.category = res.data;
        })
        .catch((err) => {
          console.log(err);
        });
    }

答案

vue的.then()方法

vue中的then方法

promise中的.then方法【待完善】

then()方法,异步执行,这里应该是将获取Mock的数据,然后赋值给category这个路由。

posted @ 2022-06-23 16:13  黄子涵  阅读(237)  评论(0编辑  收藏  举报