EmberJS — 配置應用和 Ember CLI



你可以配置 Ember App 和 CLI 以管理應用環境。環境配置檔案位於 config/environment.js。它包含以下程式碼結構 −

module.exports = function(environment) {
   var ENV = {
      modulePrefix: 'query-params', //it is the name of application
      environment: environment,
      baseURL: '/',
      locationType: 'auto',
      EmberENV: {
         
         FEATURES: {
            // Here you can enable experimental features on an ember canary build
            // e.g. 'with-controller': true
         }
      },

      APP: {
         // Here you can pass flags/options to your application instance
         // when it is created
         API_HOST: 'https://:3000'
      }
   };

   if (environment === 'development') {
      //code here
   }

   if (environment === 'test') {
      //code here
   }

   if (environment === 'production') {
   }

   return ENV;
};

ENV 物件包含以下三個鍵 −

  • EmberENV − 它提供 Ember 功能標誌。

  • APP − 用來向你的應用例項傳遞標誌/選項。

  • environment − 它提供當前環境名稱,例如 development、productiontest

配置 Ember CLI

你可以透過向 .ember-cli 檔案(位於你應用的根目錄下)新增配置來配置 Ember CLI。

例如,你可以使用命令 ember server --port 8080 從命令列傳遞埠號。此配置可以新增到 .ember-cli 檔案中,如下所示 −

{
   "port" : 8080
}
emberjs_configuring_emberjs.htm
廣告
© . All rights reserved.