Ember.js - 应用未从 enviroment.js 加载所有参数
Ember.js - App doesn't load all params from enviroment.js
我的应用程序没有加载 enviroment.js 文件中的所有参数,只有默认情况下的参数。
我安装这个包
ember-g-recaptcha 然后你需要在配置文件中添加一个参数。
问题是我用 ember-cli 创建了一个演示应用程序并且我没有工作,但在我的真实应用程序中却没有,也许有人知道为什么不加载参数。
我尝试更改package.json中模块的版本,但没有运气,但我认为仍然有解决方案。
在我的应用程序中,当您执行此控制台日志时,配置文件的对象会抛出此消息:
console.log(Ember.getOwner(this).resolveRegistration('config:environment'));
Object {
modulePrefix: "listings-search",
environment: "development",
rootURL: "/",
EmberENV: Object,
APP: Object, ember-cli-mirage: Object, exportApplicationGlobal: true
}
在演示应用程序中,结果如下:
Object {
modulePrefix: "lala",
environment: "development",
rootURL: "/",
locationType: "auto",
gReCaptcha: Object,
EmberENV: Object,
APP: Object, ember-cli-mirage: Object, exportApplicationGlobal: true
}
这是我的 enviroment.js 文件
/* jshint node: true */
module.exports = function(environment) {
var ENV = {
modulePrefix: 'listings-search',
environment: environment,
rootURL: '/',
locationType: 'auto',
gReCaptcha: {
siteKey: 'asdasdads'
},
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
// ENV['ember-cli-mirage'] = {
// enabled: false
// }
}
if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
if (environment === 'production') {
}
return ENV;
};
此外,当我尝试按照官方指南在 link 中所说的方式访问我的 environment.js 时,在控制台中抛出此错误:
Could not find module `/appname/config/environment` imported from `appname/components/name-component`
版本:
- ember: "~2.9.0"
- ember-cli: 2.14.0
- 节点:8.2.0
- os:达尔文 x64
问题是 Ember.js 将 Enviroment.js 文件注入到 HTML 的元标记中,我没有任何了解这一点是因为文档对此没有任何说明。
我们在没有路由的情况下使用 ember 的不同策略,因此元标记在代码中被硬编码。我没有看到它(我也没有注意这个,因为我不知道元标记中的配置参数)
从Ember.js 2.3开始,我们可以在西兰花文件(ember-cli-build.js)中设置参数storeConfigInMeta: false
并且配置文件将嵌入到我们的 javascript 文件中。
我的应用程序没有加载 enviroment.js 文件中的所有参数,只有默认情况下的参数。
我安装这个包 ember-g-recaptcha 然后你需要在配置文件中添加一个参数。
问题是我用 ember-cli 创建了一个演示应用程序并且我没有工作,但在我的真实应用程序中却没有,也许有人知道为什么不加载参数。
我尝试更改package.json中模块的版本,但没有运气,但我认为仍然有解决方案。
在我的应用程序中,当您执行此控制台日志时,配置文件的对象会抛出此消息:
console.log(Ember.getOwner(this).resolveRegistration('config:environment'));
Object {
modulePrefix: "listings-search",
environment: "development",
rootURL: "/",
EmberENV: Object,
APP: Object, ember-cli-mirage: Object, exportApplicationGlobal: true
}
在演示应用程序中,结果如下:
Object {
modulePrefix: "lala",
environment: "development",
rootURL: "/",
locationType: "auto",
gReCaptcha: Object,
EmberENV: Object,
APP: Object, ember-cli-mirage: Object, exportApplicationGlobal: true
}
这是我的 enviroment.js 文件
/* jshint node: true */
module.exports = function(environment) {
var ENV = {
modulePrefix: 'listings-search',
environment: environment,
rootURL: '/',
locationType: 'auto',
gReCaptcha: {
siteKey: 'asdasdads'
},
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
// ENV['ember-cli-mirage'] = {
// enabled: false
// }
}
if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
if (environment === 'production') {
}
return ENV;
};
此外,当我尝试按照官方指南在 link 中所说的方式访问我的 environment.js 时,在控制台中抛出此错误:
Could not find module `/appname/config/environment` imported from `appname/components/name-component`
版本:
- ember: "~2.9.0"
- ember-cli: 2.14.0
- 节点:8.2.0
- os:达尔文 x64
问题是 Ember.js 将 Enviroment.js 文件注入到 HTML 的元标记中,我没有任何了解这一点是因为文档对此没有任何说明。
我们在没有路由的情况下使用 ember 的不同策略,因此元标记在代码中被硬编码。我没有看到它(我也没有注意这个,因为我不知道元标记中的配置参数)
从Ember.js 2.3开始,我们可以在西兰花文件(ember-cli-build.js)中设置参数storeConfigInMeta: false
并且配置文件将嵌入到我们的 javascript 文件中。