1、创建全局文件
Global.vue
<script>
//const serverSrc='http://200.200.0.1:8001'; //如果是本地调试运行状态请用这个地址
const serverSrc = '..'; //如果是打包时请用这个
export default {
serverSrc
}
</script>
2、全局引入
main.js
import global_ from './Global' //引用
Vue.prototype.GLOBAL = global_; //定义全局变量名
3、页面方法使用
//this.GLOBAL.serverSrc 全局地址
slectList() {
/*接口请求班级*/
this.$http.post(this.GLOBAL.serverSrc + '/api/login/login1', {
}, {
headers: {
},
emulateJSON: true
}).then((res) => {
}).catch(err => {
})
},