在vue项目中设置BASE_URL

vue

  1.在config文件夹中新建global.js文件

const BASE_URL = 'http://192.168.1.62:8080/rest/'

export default {

BASE_URL

}

  2.在入口文件中引入,设置为全局变量

import global_ from '../config/global.js'

Vue.prototype.GLOBAL = global_;

  3.在有需要的地方引入baseUrl

created() {

const baseUrl=this.GLOBAL.BASE_URL

// const classId=this.$route.query.classId

console.log(baseUrl)

},

http://192.168.1.62:8080/rest/  //这个是上面打印的baseUrl

以上是 在vue项目中设置BASE_URL 的全部内容, 来源链接: utcz.com/z/376621.html

回到顶部