Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript config.ts仅返回nuxt中的第一个对象_Javascript_Vue.js_Environment Variables_Nuxt.js_Config - Fatal编程技术网

Javascript config.ts仅返回nuxt中的第一个对象

Javascript config.ts仅返回nuxt中的第一个对象,javascript,vue.js,environment-variables,nuxt.js,config,Javascript,Vue.js,Environment Variables,Nuxt.js,Config,我有这个config.ts文件: const config = { staging:{ baseUrl: 'someUrls/stag', authEndpointUrl: '', pubnubEndpointUrl: '' }, development: { baseUrl: 'someUrl/dev', authEndpointUrl: '', pubnubEndpointUrl: '' }, production: {

我有这个config.ts文件:


const config = {
  staging:{
    baseUrl: 'someUrls/stag',
    authEndpointUrl: '',
    pubnubEndpointUrl: ''
  },
  development: {
    baseUrl: 'someUrl/dev',
    authEndpointUrl: '',
    pubnubEndpointUrl: ''
  },
  production: {
    baseUrl: 'someUrl/prod',
    authEndpointUrl: '',
    pubnubEndpointUrl: ''
  }
}

const nodeEnv = process.env.NODE_ENV ;

module.exports = config[nodeEnv]
这是我的
numxt.config.js

import config from './config.ts';

.
.
.

  env:{
    config
  },
.
.
.

在我的应用程序中,如果我使用
process.env.config.baseUrl
,它只返回第一个对象的
baseUrl
'someUrls/stag'。如果我在我的
config.ts
中更改
staging
development
的位置,它将返回
baseUrl:'someUrl/dev'
(同样是第一个对象)。如何从不同的对象(如
production`)获取baseUrl

我尝试了
process.env.config.production.baseUrl
,但它返回null!如何访问我的
config.ts
文件中的不同对象