Angular Material 中常用的组件及其使用代码示例

一、按钮(MatButton)
Angular Material 的按钮组件提供了不同的样式和行为。

<button mat-button>Basic Button</button>
<button mat-raised-button color="primary">Raised Button</button>
<button mat-stroked-button color="accent">Stroked Button</button>
<button mat-flat-button color="warn">Flat Button</button>

在上述代码中:

  • mat-button 是基本的按钮样式,通常比较扁平。
  • mat-raised-button 是凸起的按钮,通过 color="primary" 可以将其颜色设置为主题的主要颜色。
  • mat-stroked-button 是带有边框的按钮,color="accent" 可以设置为主题的强调色。
  • mat-flat-button 是扁平按钮,color="warn" 可以设置为警告色。

二、输入框(MatInput)
用于用户输入文本信息。

<mat-form-field appearance="fill">
  <mat-label>Input</mat-label>
  <input matInput placeholder="Enter your name">
</mat-form-field>
  • mat-form-field 是输入框的容器,appearance="fill" 可以设置其外观样式。
  • mat-label 为输入框提供标签。
  • matInput 指令应用于标准的 HTML 输入元素,为其提供 Angular Material 的样式和行为。

三、卡片(MatCard)
用于显示内容,如文本、图像等。

<mat-card>
  <mat-card-header
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值