美文网首页
webpack打包VUE项目读取外部配置文件,灵活配置域名

webpack打包VUE项目读取外部配置文件,灵活配置域名

作者: 我是syq吖 | 来源:发表于2021-08-31 13:09 被阅读0次

1.在index.html中引入js
<script src="./static/config.js"></script>
2.man.js

if (process.env.NODE_ENV === "development") {
  // 开发模式
  Vue.prototype.$SGW_URL = process.env.SGW_URL;
  Vue.prototype.$rootUrl = process.env.API_ROOT;
  Vue.prototype.$locationhref = process.env.location_href;
  Vue.prototype.$Province = process.env.Province;
  Vue.prototype.$API_City = process.env.API_City;
  Vue.prototype.$HKEZWECHAT_URL = process.env.HKEZWECHAT_URL;
  Vue.prototype.$memberhref = process.env.member_href;
  Vue.prototype.$NoSubUrl = process.env.No_SubUrl;
  Vue.prototype.$CBC_ENV = process.env.CBC_ENV;
  Vue.prototype.$SendMsg = process.env.SendMsg;
  Vue.prototype.$CanPay = process.env.CanPay;
  Vue.prototype.$vconsole = GlobConfig.vconsole;
} else {
  // 打包模式
  Vue.prototype.$SGW_URL = GlobConfig.SGW_URL;
  Vue.prototype.$rootUrl = GlobConfig.API_ROOT;
  Vue.prototype.$locationhref = GlobConfig.location_href;
  Vue.prototype.$Province = GlobConfig.Province;
  Vue.prototype.$API_City = GlobConfig.API_City;
  Vue.prototype.$HKEZWECHAT_URL = GlobConfig.HKEZWECHAT_URL;
  Vue.prototype.$memberhref = GlobConfig.member_href;
  Vue.prototype.$NoSubUrl = GlobConfig.No_SubUrl;
  Vue.prototype.$CBC_ENV = GlobConfig.CBC_ENV;
  Vue.prototype.$SendMsg = GlobConfig.SendMsg;
  Vue.prototype.$CanPay = GlobConfig.CanPay;
  Vue.prototype.$vconsole = GlobConfig.vconsole;
}

相关文章

网友评论

      本文标题:webpack打包VUE项目读取外部配置文件,灵活配置域名

      本文链接:https://www.haomeiwen.com/subject/toqziltx.html