html - 使用 Angular 材质创建数字微调器?
问题描述
Angular Material 有数字微调器吗?我从这个问题尝试了这个演示:
<mat-form-field>
<input
type="number"
class="form-control"
matInput
name="value"
placeholder="Slab"
formControlName="value">
</mat-form-field>
但它不渲染。我打算创建一个 Stackblitz,但它不适用于 Angular 12。
想法?
解决方案
它只适用于.css。您在包装器 div matSuffix 中包含两个按钮 mat-icon-button
一个例子(disclammer,真的我不是很擅长css,很确定有更好的方法来获得相同的
.wrapper-indicator{
position:relative;
height:1.5rem;
width:1.5rem;
overflow:none;
}
.wrapper-indicator .up,.wrapper-indicator .down{
position:absolute;
right: 0;
font-size:.5em;
height: 1.25rem!important;
width: 1.25rem!important;
}
.wrapper-indicator .up{
top:-.25rem;
}
.wrapper-indicator .down{
top:1rem;
}
并使用
<mat-form-field appearance="fill" floatLabel="always">
<mat-label>Amount</mat-label>
<input matInput type="number" class="example-right-align" placeholder="0">
<div matSuffix class="wrapper-indicator">
<button class="up" mat-icon-button >
<mat-icon>expand_less</mat-icon>
</button>
<button class="down" mat-icon-button >
<mat-icon>expand_more</mat-icon>
</button>
</div>
</mat-form-field>
如果您使用 type="number",则直接更新mat-input 创建一个微调器。奇怪,当我输入时不显示“微调器”。看一下github中的代码,“类型”是 a @Input
,所以想象一下它几乎是在旧版本的 Angulartype="number"
之后编写的 matInput
推荐阅读
- kubectl - 如何在一个 Google Cloud 帐户中管理多个 GKE 项目
- node.js - Chrome net::ERR_HTTP2_PROTOCOL_ERROR 200 重新连接后
- java - 错误的 ip 忽略超时
- ansible - Ansible 模板循环变量
- python - pygame KEYUP 只注册 KEYDOWN
- laravel - Laravel Mix - 是否需要链接来确保执行顺序?
- arrays - 如何引用而不是复制另一个选项卡中的数据?
- android - 基于 App Variant 构建配置(BuildType + Flavor)
- c# - DateTimeOffset:DateTime 是本地时间还是 UTC 时间?
- batch-file - 用于弹出 USB 驱动器的 .BAT 命令(卸载、移除 - 您选择正确的动词)