angular 居中_Angular Material design设计

官网:

优秀的Meterial design站点:

并不是万能的,都有约束条件。

优点:兼容性好,可扩展性强,可测试性好,对主题的支持好。

缺点:组件不是特别丰富。

安装:

//其它方式

$ sudo cnpm i --save @angular/material@2.0.0-beta.7

$ sudo yarn add @angular/material --save

$ npm i @angular/material --save

安装的版本是"@angular/material": "^7.1.0",

有个依赖要手动安装

$ sudo yarn add @angular/cdk@6.4.6 --save

一、相关报错

1、控制台报警告:Could not find Angular Material core theme。

在styles.scss中引入angular materail主题:

@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';

内建主题有这几种:

可以用scss自定义主题。

2、ERROR Error: Found the synthetic listener @transform.start. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

3、mat-toolbar,mat-sidenav和mat-sidenav-container不是已知的元素?

Uncaught Error: Template parse errors: 'mat-icon' is not a known element: 1. If 'mat-icon' is an Angular component, then verify that it is part of this module.

应该将模块导入与组件相关的module.ts文件中。比如我是在header这个组件中用到了mat-icon,而我的header组件是放在core Module中的,那就要在core Module中去import MatIconModule,而不是在app.module中引入。

4、ERROR Error: Could not find HttpClient provider for use with Angular Material icons.

使用SVG Icon的时候依赖Http。需要导入HttpClient。

5、NewTaskComponent.html:14 ERROR Error: MatDatepicker: No provider found for DateAdapter. You must import one of the following modules at your application root: MatNativeDateModule, MatMomentDateModule, or provide a custom implementation.

使用DatePicker的时候同时要导入MatNativeDateModule用作DateFormat。

6、core.es5.js:178 Could not find HammerJS. Certain Angular Material components may not work correctly.

移动端用HammerJS去处理一些事件。

$ npm install --save hammerjs

安装好以后在coreModule中

import 'hammerjs';

二、Material组件

1、SidebarComponent侧边栏导航:

打开侧边栏

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值