-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
53 lines (45 loc) · 1.21 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import Vue from 'vue';
import VueResource from 'vue-resource';
import VueProgressBar from 'vue-progressbar';
import VueResourceProgressBarInterceptor from './../src/vue-resource-progressbar-interceptor';
window.Vue = Vue;
Vue.use(VueResource);
Vue.use(VueProgressBar);
Vue.use(VueResourceProgressBarInterceptor);
new Vue({
template: `
<div>
<vue-progress-bar></vue-progress-bar>
<div>
<button @click="request()">Make request</button>
<button @click="longRequest()">Make long request (5 sec)</button>
<button @click="superLongRequest()">Make super long request (10 sec)</button>
</div>
<div v-if="loading">
Loading...
</div>
</div>
`,
data() {
return {
loading: false,
};
},
methods: {
request() {
this.loading = true;
this.$http.get('https://httpbin.org/ip').finally(this.finish);
},
longRequest() {
this.loading = true;
this.$http.get('https://httpbin.org/delay/5').finally(this.finish);
},
superLongRequest() {
this.loading = true;
this.$http.get('https://httpbin.org/delay/10').finally(this.finish);
},
finish() {
this.loading = false;
},
},
}).$mount('#app');