2017-07-20 38 views
1

我的應用程序不加載從enviroment.js文件中的所有參數,只是在默認情況下的那些加載所有PARAMS。Ember.js - 應用程序不會從enviroment.js

我安裝這個包 ember-g-recaptcha然後你需要把一個參數放在配置文件中。

的問題是,我創建與Ember-CLI和I'ts工作演示應用程序,但在我真正的應用程序是不是,也許有人有,爲什麼不加載任何PARAMS想法。

我嘗試更改package.json中的模塊版本,但沒有運氣,但我認爲仍然是那裏的解決方案。

在我的應用程序配置文件的對象拋出這樣的,當你做這個控制檯日誌:

的console.log(Ember.getOwner(本).resolveRegistration(「配置:環境」));

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; 
}; 

此外,當我試圖訪問我environment.js在這方式,官方指導在這個link說,拋出此錯誤控制檯:

Could not find module `/appname/config/environment` imported from `appname/components/name-component` 

版本:

  • 燼: 「〜2.9.0」
  • 燼-CLI:2.14.0
  • 節點:8.2.0
  • OS:達爾文64
+0

您使用的是哪個版本的ember/ember-cli? – Bracke

+0

燼-CLI:2.14.0 節點:8.2.0 OS:達爾文64 – Merlyn007

+0

你有沒有更換「應用程序名稱」與您的應用程序的名稱? – Bracke

回答

0

問題是,Ember.js注入Enviroment.js文件在HTML元標記,我沒有這樣的任何知識,因爲文件並沒有說明任何第是。

我們正在使用的使用餘燼沒有路線不同的策略,所以元標記是在代碼harcoded。我沒有看到它(我也沒有注意到這一點,因爲我不知道meta標籤中的配置參數)

由於Ember.js 2.3我們可以在我們的西蘭花文件(ember-cli-build.js)參數storeConfigInMeta: false和配置文件將嵌入到我們的JavaScript文件中。

相關問題