柚子快报激活码778899分享:Vue 多环境配置

http://yzkb.51969.com/

没有使用 package.json 进行配置 ,改配置时不需要重新打包 Vue 多环境配置 package.json

settings.js

window.environment="dev"

window.version = 'v1.0.1'

window.settings.dev = {

environment: '开发',

apiUrl: 'http://localhost:9091'

}

window.settings.test = {

environment: '测试',

apiUrl: 'http://192.168.0.100:9091'

}

window.settings.pre = {

environment: '预发布',

apiUrl: 'http://192.168.0.101:9091'

}

window.settings.pro = {

environment: '正式',

apiUrl: 'http://192.168.0.102:9091'

}

config/index.js

let _settings = '';

if (window.environment == 'dev') {

_settings = window.settings.dev

} else if (window.environment == 'test') {

_settings = window.settings.test

} else if (window.environment == 'pre') {

_settings = window.settings.pre

} else if (window.environment == 'pro') {

_settings = window.settings.pro

} else {

_settings = window.settings.dev

}

export default {

env: _settings,

}

vue

{{config.env.environment}}

 main.js

/**

* @description 全局注册应用配置

*/

Vue.prototype.$config = config

---------

{{$config.env.environment}}

 

柚子快报激活码778899分享:Vue 多环境配置

http://yzkb.51969.com/

精彩文章

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。

发表评论