Ember CLI 使用教程
2026-01-18 09:42:14作者:胡易黎Nicole
1. 项目的目录结构及介绍
Ember CLI 项目的目录结构遵循一定的约定,以下是主要的目录和文件介绍:
my-app/
├── app/
│ ├── adapters/
│ ├── components/
│ ├── controllers/
│ ├── helpers/
│ ├── models/
│ ├── routes/
│ ├── serializers/
│ ├── services/
│ ├── styles/
│ ├── templates/
│ └── index.html
├── config/
│ ├── environment.js
│ └── optional-features.json
├── public/
│ ├── assets/
│ └── index.html
├── tests/
│ ├── integration/
│ ├── unit/
│ └── test-helper.js
├── vendor/
├── .editorconfig
├── .ember-cli
├── .gitignore
├── .jshintrc
├── .travis.yml
├── bower.json
├── ember-cli-build.js
├── package.json
├── README.md
└── testem.js
主要目录和文件说明:
app/: 包含应用程序的主要代码,如组件、控制器、模型等。config/: 包含应用程序的配置文件,如environment.js。public/: 包含静态资源文件。tests/: 包含测试代码。vendor/: 包含第三方库文件。ember-cli-build.js: 构建配置文件。package.json: 项目依赖和脚本配置文件。
2. 项目的启动文件介绍
Ember CLI 项目的启动文件主要是 app/app.js 和 app/index.html。
app/app.js
这是应用程序的入口文件,负责初始化 Ember 应用实例:
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
const App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
});
loadInitializers(App, config.modulePrefix);
export default App;
app/index.html
这是应用程序的主 HTML 文件,包含应用程序的根元素和一些基本的 meta 标签:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>MyApp</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{content-for "head"}}
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/my-app.css">
{{content-for "head-footer"}}
</head>
<body>
{{content-for "body"}}
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/my-app.js"></script>
{{content-for "body-footer"}}
</body>
</html>
3. 项目的配置文件介绍
Ember CLI 项目的主要配置文件位于 config/ 目录下。
config/environment.js
这是主要的配置文件,包含应用程序的环境配置:
'use strict';
module.exports = function(environment) {
let ENV = {
modulePrefix: 'my-app',
podModulePrefix: 'my-app/pods',
environment,
rootURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},
APP: {
// Here you can pass flags/options to your application instance
登录后查看全文
热门项目推荐
相关项目推荐
GLM-5智谱 AI 正式发布 GLM-5,旨在应对复杂系统工程和长时域智能体任务。Jinja00
GLM-5.1GLM-5.1是智谱迄今最智能的旗舰模型,也是目前全球最强的开源模型。GLM-5.1大大提高了代码能力,在完成长程任务方面提升尤为显著。和此前分钟级交互的模型不同,它能够在一次任务中独立、持续工作超过8小时,期间自主规划、执行、自我进化,最终交付完整的工程级成果。Jinja00
LongCat-AudioDiT-1BLongCat-AudioDiT 是一款基于扩散模型的文本转语音(TTS)模型,代表了当前该领域的最高水平(SOTA),它直接在波形潜空间中进行操作。00- QQwen3.5-397B-A17BQwen3.5 实现了重大飞跃,整合了多模态学习、架构效率、强化学习规模以及全球可访问性等方面的突破性进展,旨在为开发者和企业赋予前所未有的能力与效率。Jinja00
HY-Embodied-0.5这是一套专为现实世界具身智能打造的基础模型。该系列模型采用创新的混合Transformer(Mixture-of-Transformers, MoT) 架构,通过潜在令牌实现模态特异性计算,显著提升了细粒度感知能力。Jinja00
FreeSql功能强大的对象关系映射(O/RM)组件,支持 .NET Core 2.1+、.NET Framework 4.0+、Xamarin 以及 AOT。C#00
项目优选
收起
deepin linux kernel
C
27
14
OpenHarmony documentation | OpenHarmony开发者文档
Dockerfile
657
4.26 K
Ascend Extension for PyTorch
Python
502
606
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
939
862
Oohos_react_native
React Native鸿蒙化仓库
JavaScript
334
378
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
390
284
AscendNPU-IR是基于MLIR(Multi-Level Intermediate Representation)构建的,面向昇腾亲和算子编译时使用的中间表示,提供昇腾完备表达能力,通过编译优化提升昇腾AI处理器计算效率,支持通过生态框架使能昇腾AI处理器与深度调优
C++
123
195
openGauss kernel ~ openGauss is an open source relational database management system
C++
180
258
🎉 (RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue3 & Vite、Element Plus 的前后端分离权限管理系统
Vue
1.54 K
891
昇腾LLM分布式训练框架
Python
142
168