获取环境变量
// config/index.js
const env = process.env.NODE_ENV;
const configObj = {
production: {
baseUrl: "https://production.com/"
},
development: {
baseUrl: 'http://development.com/'
}
};
export default {...configObj[env] };
vue页面中使用
根据环境变量取值
// detail.vue
import config from '@/config/index'
path: config.baseUrl