Angular6项目搭建
参照 草根专栏- ASP.NET Core + Ng6 实战:https://v.qq.com/x/page/b076702elvw.html
安装工具:
- Nodejs, npm 最新版, https://nodejs.org/en/
- Angular CLI, npm install -g @angular/cli
- Visual Studio Code, https://code.visualstudio.com/
Angular Cli
- https://github.com/angular/angular-cli
- https://cli.angular.io/
- ng new
- ng generate
- ng serve
- Test, Lint, Format
- 要看文档!!!
项目搭建
1、在cmd 输入 ng new blog-client --style scss --dry-run 项目创建预览
2、在项目目录下输入 code . 命令打开vscode
3、 安装 angularMaterial npm install --save @angular/material @angular/cdk @angular/animations 官网 :https://material.angular.io/guides
4、 在 app.module.ts 中添加
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; @NgModule({
...
imports: [BrowserAnimationsModule],
...
})
export class PizzaPartyAppModule { }
5、在 app.module.ts 中添加
import {MatButtonModule, MatCheckboxModule} from '@angular/material'; @NgModule({
...
imports: [MatButtonModule, MatCheckboxModule],
...
})
export class PizzaPartyAppModule { }
6、在scss中添加
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
7、npm install --save hammerjs 在main.ts 导入
import 'hammerjs';
8、 ng g module blog --routing --spec false
9、全局设置 spec为false,在angular.json中设置
"@schematics/angular:module": {
"spec": false
}
10、 ng g module shared/material 将angularMateria组件都导入
11、将 MaterialModule 导入 blog.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {MaterialModule} from '../shared/material/material.module'
import { BlogRoutingModule } from './blog-routing.module'; @NgModule({
imports: [
CommonModule,
BlogRoutingModule,
MaterialModule
],
declarations: []
})
export class BlogModule { }
12、 ng g component blog/blog-app --flat --inline-style --inline-template --module blog 创建主组件
13、配置路由:blog-routing.module.ts
const routes: Routes = [
{path: '', component: BlogAppComponent}
]; @NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class BlogRoutingModule { }
13、配置主路由:app.module.ts
const routers: Routes = [
{path: 'blog', loadChildren: './blog/blog.module#BlogModule'},
{path: '**' , redirectTo: 'blog' }
]; @NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule, BrowserAnimationsModule, MatButtonModule, MatCheckboxModule,
RouterModule.forRoot(routers)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
14、配置路由插座:app.component.html
<router-outlet></router-outlet>
15、ng g c blog/components/sidenav
16、ng g c blog/components/toolbar
17、 导入图标:blog-app.component.ts
export class BlogAppComponent implements OnInit {
constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
iconRegistry.addSvgIcon('baseline-more_vert', sanitizer.bypassSecurityTrustResourceUrl('/assets/baseline-more_vert-24px.svg'));
iconRegistry.addSvgIcon('baseline-menu', sanitizer.bypassSecurityTrustResourceUrl('/assets/baseline-menu-24px.svg'));
}
ngOnInit() {
}
18、在app.module.ts 中添加 HttpClientModule
图标下载网站:https://material.io/tools/icons/?icon=more_vert&style=baseline
Angular6项目搭建的更多相关文章
- Intellij IDEA Java web 项目搭建
Java web 项目搭建 简介 在上一节java web环境搭建中,我们配置了开发java web项目最基本的环境,现在我们将采用Spring MVC+Spring+Hibernate的架构搭建一个 ...
- 项目搭建系列之一:使用Maven搭建SpringMVC项目
约定电脑都安装了eclipse,且已配置好Maven以及eclipse插件. 1.Eclipse 2.maven 3.Eclipse 需要安装maven插件.url:maven - http://do ...
- maven项目搭建
一.Maven简介 Maven是基于Java平台的项目构建(mvn clean install).依赖管理(中央仓库,Nexus)和项目信息管理的项目管理工具. Maven是基于项目对象模型(POM) ...
- maven3常用命令、java项目搭建、web项目搭建详细图解
http://blog.csdn.net/edward0830ly/article/details/8748986 ------------------------------maven3常用命令-- ...
- Java web 项目搭建
Java web 项目搭建 简介 在上一节java web环境搭建中,我们配置了开发java web项目最基本的环境,现在我们将采用Spring MVC+Spring+Hibernate的架构搭建一个 ...
- requirejs + vue 项目搭建2
上篇是年后的项目搭建的,时间比较仓促,感觉有点low 1.gulp-vue 文件对公用js的有依赖,以后别的同事拿去搭其他项目,估计会被喷 2.不支持vue-loader一样写模版语言和es6语法 最 ...
- requirejs + vue 项目搭建
以前都是支持 司徒正美 的,毕竟咱们也是跟着 司徒正美 一起走进了前端的世界.所以一般MVVM都是用avalon的,当然也是考虑到项目需要支持IE6,7,8的考虑.当然在用的时候也有一些小坑和bug, ...
- Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建(转)
这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 如果还没有搭建好环境( ...
- freemarker + spring mvc + spring + mybatis + mysql + maven项目搭建
今天说说搭建项目,使用freemarker + spring mvc + spring + mybatis + mysql + maven搭建web项目. 先假设您已经配置好eclipse的maven ...
随机推荐
- 如何在html中插入图片
HTML内容元素中图片元素 使用img元素:src属性:图片路径. alt属性:图片无法显示的时候使用替代文本,title属性:鼠标悬停时显示文本内容. 在同一张图片上点击不同的位置链接到不同的页面上 ...
- python3爬虫编码问题
使用爬虫爬取网页经常遇到各种编码问题,因此产生乱码今天折腾了一天,全部总结一遍环境:win10,pycharm,python3.41.首先先来网页编码是utf-8的:以百度首页为例:使用request ...
- MyBatis之properties配置
这些属性都是可外部配置且可动态替换的,既可以在典型的 Java 属性文件中配置,亦可通过 properties 元素的子元素来传递.例如: <properties resource=" ...
- CoacoaPods安装使与使用超级详细教程
对于一个iOS开发的初学者来说,并不知道第三方类库的存在,知道了也不知道如何使用,那么下面便来介绍一下使用方法. iOS开发常用的第三方类库是GitHub:https://github.com/ 在上 ...
- 我的前端工具集(六)Ajax封装token
我的前端工具集(六)Ajax封装token liuyuhang原创,未经允许禁止转载 在单点登陆中,或登陆验证后,不应该每次都验证用户名和密码, 也不应该将用户名密码存入cookie中(虽然很多都 ...
- Linux中文件函数(一)
一.stat.fstat.fstatat.lstat函数 函数的原型为: #include <sys/stat.h> int stat(const char *restrict pathn ...
- Linux CentOs下安装lamp
以home目录为例,进入/home cd /home 是否安装gcc与gcc-c++,没有则安装 yum -y install gcc gcc-c++ 一.安装Apache 下载httpd wget ...
- 解决echarts 鼠标悬浮提示 文本提示问题。
参考文章:https://www.jianshu.com/p/aa585c304660 官方文章样式详解:http://echarts.baidu.com/option.html#tooltip.fo ...
- Asp.Net Core使用Log4Net优化日志【项目开源】
我在前一篇文章中介绍了一种使用Log4Net的方法,但是那种方法打出来的日志不是很直观 然后我前不久阅读了一篇非常不错的博客:https://www.cnblogs.com/guolianyu/p/9 ...
- Mysql是否开启binlog日志&开启方法
运行sql show variables like 'log_bin'; 如果Value 为 OFF 则为开启日志文件 如何开启mysql日志? 找到my,cnf 中 [mysqld] 添加如下 ...