Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

问题描述

vuecreated方法中的函数执行顺序。

相关代码

 created() {
    this.fetchMinerTypesList()
    this.fetchCoinsList()
    this.fetchMiners()
    console.log(this.$route.query)
    this.fetchMinersList()
  },

你期待的结果是什么?实际看到的错误信息又是什么?

希望在this.fetchMinerTypesList()this.fetchCoinsList()两个函数执行完,再执行this.fetchMiners();最后执行this.fetchMinersList()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

可以使用async/await

 async created() {
    await this.fetchMinerTypesList()
    await this.fetchCoinsList()
    await this.fetchMiners()
    await this.fetchMinersList()
  },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...