带有Axios的VUE需要5到7秒的API调用,并带有小数据
美好的一天,
我的VUE应用程序有很大的问题,即我的API电话非常慢。
我有一个Laravel的后端,可以及时提供数据,该数据通过域。
但是,在我的仪表板中,我在其中拨打了三个API调用,它需要5到8秒钟才能加载内容:
因此,用户大量抱怨加载时间。 在代码中,我目前将呼叫调用如下:
async mounted() {
this.personalDeletegatesId = userInfo.user.delegatesid
this.getTasks()
this.getAddresses()
this.getRequestTypes()
},
每个函数都是作为异步方法创建的。 应用程序中的应用程序既不快。
getAddresses: async function () {
this.$http.get('/addresses/delegates/' + userInfo.user.delegatesid)
.then(function (response) {
this.items = uniqueElementsBy(response.data[0], (a, b) => a.id == b.id)
this.itemsnotasks = uniqueElementsBy(response.data[1], (a, b) => a.id == b.id)
this.itemsfav = uniqueElementsBy(response.data[2], (a, b) => a.id == b.id)
this.getCounts()
}.bind(this))
},
getTasks: async function () {
this.$http.get('/salestasks/delegates/' + userInfo.user.delegatesid)
.then(function (response) {
this.itemsTasks = uniqueElementsBy(response.data, (a, b) => a.salestasks_id == b.salestasks_id)
}.bind(this))
},
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论