Angular搭建脚手架

一、安装CLI: css

cnpm install -g @angular/clihtml

//卸载: npm uninstall -g @angular/cli   npm cache clean前端

二、检测是否成功: git

ng –version  or  ng vtypescript

三、新建项目npm

ng new ng-app //ng-app能够本身命名项目名称json

cd ng-app   //进入ng-app浏览器

ng serve     //启服务app

http://localhost:4200/ 访问angular项目编辑器

四、项目结构说明

文件

说明

E2e

应用的端对端(e2e)测试,用 Jasmine 写成并用 protractor 端对端测试运行器测试。

Node_modules

依赖包

Src

 

   App

Angular应用文件

      App.module.ts

 

      App.component.ts

 

   assets

资源文件

   Environments

环境配置:开发、部署

   Index.html

应用的宿主页面。 它以特定的顺序加载一些基本脚本。 而后它启动应用,将根AppComponent放置到自定义<my-app>标签里。

   Main.ts

 

   Polyfills.ts

处理浏览器兼容问题

   Tsconfig.app.json

Typescript编译配置

   Tsconfig.spec.json

Typescript测试编译配置

   Typings.d.ts

类型定义文件

//.angular-cli.json

Cli配置文件

.editorconfig

统一代码风格工具配置,不支持的须要安装插件

.gitignore

Git配置文件

//Karma.conf.js

在测试指南中提到的 karma 测试运行器的配置。

//Package.json

项目指定npm依赖包

Protractor.conf.js

protractor 端对端 (e2e) 测试器运行器的配置。

Tsconfig.json

Typescript编译配置

Tslint.json

Typescript语法检查器

4.1根目录

1、三大目录

e2e目录:是端到端(end-to-end)测试;
mode_modules
目录:是angular6.1项目所依赖的第三方模块库文件;
src
目录:这时放置了咱们项目的全部文件。

2、其余文件

.editorconfig给你的编辑器看的一个简单配置文件
.gitignore
git 排除文件
angular.json
angular cli 的配置文件
package.json
npm 配置文件,项目使用到的第三方依赖包
protractor.conf.js
:运行 ng e2e 的时候会用到
README.md
:项目的基础文档
tsconfig.json
TypeScript 编译器的配置
tslint.json
:运行 ng lint 时会用到

4.2根目录下的src目录

1、src下的三大目录

app目录:咱们要编写的项目文件都在这个目录下;
assets
目录:放置静态资源;
environments
目录:环境文件目录;

2、其余文件

browserslist:前端工具之间共享[目标浏览器]的配置文件
favicon.ico
:浏览器书签栏中图标
index.html
:主页面 HTML 文件
karma.conf.js
:运行 ng test 时会用到它
main.ts
:应用的主要入口点
polyfills.ts
腻子脚本(polyfill)能把浏览器对 Web不一样点进行标准化
styles.css
:全局样式
test.ts
:单元测试的主要入口点
tsconfig.app.json
TypeScript 编译器的配置文件
tslint.json
:额外的 Linting 配置

4.3根/src/app目录

 

app.component.css:组件css样式文件
app.component.html
:组件html文件
app.component.spec.ts
:单元测试文件
app.component.ts
:组件typescript文件
app.module.ts
:模块文件,用来全局导入声明模块组件和服务等

相关文章
相关标签/搜索