mat*_*ang 2 angular-material angular-material2 angular-material-5
我正在尝试在我的项目中使用 Angular Material 并且导入了标签,但并非所有样式都在那里。
在我的 HTML 中:
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker startView="year" [startAt]="startDate"></mat-datepicker>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
它应该显示:
但它显示:
我添加@import "~@angular/material/prebuilt-themes/indigo-pink.css";
到 style.css 并且日历显示正常,但文本字段看起来仍然很糟糕。
你需要遵循这里的一切。https://material.angular.io/guide/getting-started
尝试将此行添加到您的styles.css: @import "~@angular/material/prebuilt-themes/indigo-pink.css";
从这一步开始:https : //material.angular.io/guide/getting-started#step-4-include-a-theme
这些是您需要的导入:
import { MatDatepickerModule, MatFormFieldModule, MatNativeDateModule, MatInputModule } from '@angular/material';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
imports: [BrowserModule, FormsModule, MatDatepickerModule, MatFormFieldModule, MatNativeDateModule, MatInputModule, BrowserAnimationsModule],
...
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12651 次 |
最近记录: |