在Ember 2.2和EmberCLI中,它可以开箱即用,如下所示:
为每个环境设置URLS :
# /config/environments.js ... if (production === 'production') { ENV.API_HOST = 'http://production.server.com' } if (environment === 'development') { ENV.API_HOST = 'http://development.server.com' } ...
使用适配器中的URL :
# /app/adapters/application.js import ActiveModelAdapter from 'active-model-adapter'; import config from '../config/environment'; export default ActiveModelAdapter.extend({ namespace: 'api', host: config.API_HOST });