This repository was archived by the owner on Jun 10, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Original file line number Diff line number Diff line change 1
1
<script >
2
+ import axios from ' axios'
2
3
import Datasource from ' ./components/ServerDatasource.vue'
3
4
export default {
4
5
name: ' app' ,
5
6
components: {
6
7
Datasource
7
8
},
9
+ mounted () {
10
+ this .getSource ()
11
+ },
8
12
render (h ) {
9
13
return (
10
14
< div id= " app" >
11
- < datasource source= " http://young-falls-97690.herokuapp.com/getusers" limits= {this .limits } actions= {this .actions } columns= {this .columns }>< / datasource>
15
+ < h2 class = " text-center mb3" > Vue Datasource< / h2>
16
+ < datasource source= {this .information } limits= {this .limits } actions= {this .actions } columns= {this .columns } on- change= {this .change }>< / datasource>
12
17
< / div>
13
18
)
14
19
},
@@ -21,19 +26,15 @@ export default {
21
26
key: ' id'
22
27
},
23
28
{
24
- name: ' Name' ,
25
- key: ' name '
29
+ name: ' First Name' ,
30
+ key: ' first_name '
26
31
},
27
32
{
28
- name: ' City ' ,
29
- key: ' city ' ,
33
+ name: ' Last Name ' ,
34
+ key: ' last_name ' ,
30
35
render : function (value ) {
31
36
return ` <strong>${ value} </strong>`
32
37
}
33
- },
34
- {
35
- name: ' Company' ,
36
- key: ' company'
37
38
}
38
39
],
39
40
actions: [
@@ -98,14 +99,19 @@ export default {
98
99
}
99
100
},
100
101
methods: {
102
+ getSource () {
103
+ axios .get (` https://reqres.in/api/users?per_page=${ this .perpage } &page=${ this .page } ` ).then ((response ) => {
104
+ this .information = response .data .data
105
+ })
106
+ },
101
107
change (value ) {
102
108
this .page = value .page
103
109
this .perpage = value .perpage
104
- this .getData ()
110
+ this .getSource ()
105
111
},
106
112
searching (value ) {
107
113
this .search = value
108
- this .getData ()
114
+ this .getSource ()
109
115
}
110
116
}
111
117
}
@@ -115,6 +121,10 @@ export default {
115
121
@import url (' https://fonts.googleapis.com/css?family=Roboto:300,400,500,700' );
116
122
@import " ./assets/app.css" ;
117
123
#app {
118
- font-family : ' Roboto' !important
124
+ font-family : ' Roboto' !important ;
125
+ margin : 150px 0 ;
126
+ }
127
+ .mb3 {
128
+ margin-bottom : 30px ;
119
129
}
120
130
</style >
You can’t perform that action at this time.
0 commit comments