vue-async-loading
Using vuex to manage the loading state of asynchronous methods
Usage
; Vue;
Options
store
Vuex instance
handleError(err)
All error raised by the asyncMethods will be passed to the handleError handler, enabling you to implement global error handling, logging, etc.
Demo
;; Vue;
Now you can define async methods on your vm:
<template> <div> <div v-show="$loading.global">global</div> <div v-show="$loading.fetchData">current component</div> <div v-show="$loading['demo2/fetchData']"> other components $loading'component name/method name' </div> </div></template>; // You need to define the name to distinguish the methods of different components name: 'demo' asyncMethods: { return ; } async { const res = await ; // do something } methods: { console; console; console; } ;