从Ember addon index.js访问environment.js

时间:2021-10-25 23:58:25

I am building a Ember addon and I will like to know if there is a way to access the config/environment.js file from the root index.js. Basically I would like have the same config value used from the root index.js and a component.

我正在构建一个Ember插件,我想知道是否有办法从root index.js访问config / environment.js文件。基本上我想从根index.js和组件使用相同的配置值。

Thanks

谢谢

2 个解决方案

#1


1  

const config = this.project.config()

const config = this.project.config()

#2


0  

You can simply require it:

你可以简单地要求它:

// index.js
var environment = 'production'; // optional
var ENV = require('config/environment')(environment);
console.log(ENV.baseURL);

#1


1  

const config = this.project.config()

const config = this.project.config()

#2


0  

You can simply require it:

你可以简单地要求它:

// index.js
var environment = 'production'; // optional
var ENV = require('config/environment')(environment);
console.log(ENV.baseURL);