柚子快报激活码778899分享:Vue 多环境配置
没有使用 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
import config from '@/config'
export default {
components: {
},
data(){
return {
config:config
}
}
}
main.js
/**
* @description 全局注册应用配置
*/
Vue.prototype.$config = config
---------
本文由 用户 于 2024-04-22 发布在 夸智网,如有疑问,请联系我们。
本文链接:https://www.kuazhi.com/post/713848619.html
发表评论