File tree 2 files changed +19
-11
lines changed
2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,10 @@ let apiHome = {
9
9
10
10
// 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作
11
11
const install = ( Vue , vm ) => {
12
-
13
- // 此处没有使用传入的params参数
12
+
13
+ //api方法
14
14
let getSearch = ( params = { } ) => vm . $u . get ( apiHome . hotSearchUrl , params ) ;
15
- // 此处使用了传入的params参数,一切自定义即可
16
-
17
- let getInfo = ( params = { } ) => vm . $u . post ( apiApp . getInfo , params ) ;
15
+ let getInfo = ( params = { } ) => vm . $u . post ( apiApp . getInfo , params ) ;
18
16
19
17
// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
20
18
vm . $u . api = { getSearch, getInfo} ;
Original file line number Diff line number Diff line change 22
22
this .$u .vuex (' vuex_user.name' , ' 诗圣' );
23
23
this .$u .toast (' Hello uView!' );
24
24
// 调用getSearch接口
25
- this .$u .api .getSearch ({
26
- id: 777
27
- }).then (res => {
28
- console .log (res);
29
- })
25
+ this .getSearch ()
26
+ this .getInfo ()
30
27
},
31
28
methods: {
32
-
29
+ async getSearch (){
30
+ let params = {
31
+ id: 111
32
+ }
33
+ let res = await this .$u .api .getSearch (params)
34
+ console .log (' res' ,res)
35
+ },
36
+ async getInfo (){
37
+ let params = {
38
+ id: 222
39
+ }
40
+ let res = await this .$u .api .getInfo (params)
41
+ console .log (res)
42
+ }
33
43
}
34
44
}
35
45
</script >
You can’t perform that action at this time.
0 commit comments