目录

配置App和Ember CLI(Configuring App and 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: 'http://localhost: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
}
↑回到顶部↑
WIKI教程 @2018