File tree Expand file tree Collapse file tree 3 files changed +49
-1
lines changed
Expand file tree Collapse file tree 3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,10 @@ const setupProgress = (axios) => {
161161 currentRequests --
162162
163163 if ( Axios . isCancel ( error ) ) {
164+ if ( currentRequests <= 0 ) {
165+ currentRequests = 0
166+ $loading ( ) . finish ( )
167+ }
164168 return
165169 }
166170
Original file line number Diff line number Diff line change 1+ function sleep ( ms ) {
2+ return new Promise ( ( resolve ) => {
3+ setTimeout ( resolve , ms )
4+ } )
5+ }
6+
17module . exports = {
28 path : '/test_api' ,
3- handler ( req , res ) {
9+ async handler ( req , res ) {
10+ const query = new URL ( req . url , 'http://localhost:3000' ) . query
11+ if ( query && query . delay ) {
12+ await sleep ( query . delay )
13+ }
14+
415 res . end ( JSON . stringify ( {
516 url : req . url ,
617 method : req . method
Original file line number Diff line number Diff line change 1+ <template >
2+ <div >
3+ there should be no loading bar left over:
4+ <button @click =" test" >Fake Request</button >
5+ </div >
6+ </template >
7+
8+ <script >
9+ export default {
10+ methods: {
11+ test () {
12+ const source = this .$axios .CancelToken .source ();
13+ this .$axios
14+ .$post (
15+ " http://localhost:3000/test_api/foo/bar?delay=1000" ,
16+ { data: " test" },
17+ {
18+ cancelToken: source .token ,
19+ }
20+ )
21+ .catch ((err ) => {
22+ if (this .$axios .isCancel (err)) {
23+ console .log (" request canceled" );
24+ }
25+ });
26+
27+ setTimeout (function () {
28+ source .cancel ();
29+ }, 500 );
30+ },
31+ },
32+ };
33+ </script >
You can’t perform that action at this time.
0 commit comments