1.设置全局变量
这里我只用了2种,一种在main.js里面设置了全局变量,一种使用vuexhtml
(1).第一种,main.js里面设置
Vue.prototype.Url = 'https://xx.xx.cn/lua_bills/';
页面使用的时候能够这样用:this.Url+'openid',vue
uni.request({
url :this.Url+'openid',
method :'GET',
data :{
code:code
},
success:function(data){
}
})
(2).第二种,使用vuex,这里我使用了模块化
根目录下新建一个store文件,store下包含modules文件夹,index.js文件,getters.js文件,结构以下:
vuex
modules里面包含header.js和inquiry.js,每个文件中都包含state,mutations,actions,获取数据我都写在了getters.js文件中网络
建好store后在main.js里面引用app
import Vue from 'vue&#