在vue文件里配置所需的全局变量,然后通过export暴露出去。 如Global.vue
<script type="text/javascript">
const serverPath="http://127.0.0.1:8080";
export default{
serverPath
}
</script>
在main.js引入,将global接口放到prototype,这样以后其他组件引用global里的全局变量就可以直接通过“this.global.变量”的方式而无需import多次
import global from './Global'
Vue.prototype.
global=
global