javascript - ERROR 错误:StaticInjectorError(AppModule)[MatToolbar -> ElementRef]
问题描述
第一天使用@angular/material 时出现错误。像这样的版本:
"dependencies": {
"@angular/animations": "^6.0.3",
"@angular/cdk": "^6.2.0",
"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/forms": "^6.0.3",
"@angular/http": "^6.0.3",
"@angular/material": "^6.2.0",
...
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.6",
"@angular/cdk": "^6.2.0",
"@angular/cli": "~6.0.7",
"@angular/compiler-cli": "^6.0.3",
"@angular/language-service": "^6.0.3",
"@angular/material": "^6.2.0",
"hammerjs": "^2.0.8",
"typescript": "~2.7.2"
}
我在 app.module.ts 中导入模块:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
// the third modules
import { LayoutModule } from '@angular/cdk/layout';
import { MatToolbarModule } from '@angular/material/toolbar';
import 'hammerjs';
import { HeaderComponent } from './header/header.component';
import { BaseDataComponent } from './base-data/base-data.component';
@NgModule({
declarations: [
AppComponent,
HeaderComponent,
BaseDataComponent
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
BrowserAnimationsModule,
LayoutModule,
MatToolbarModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
然后我在html中使用mat-toolbar,但是当我在浏览器中运行它时,我在控制台中遇到错误: 我搜索了很多但仍然有问题的错误 ,有人可以帮助我吗?请!
解决方案
推荐阅读
- qt - QTCP/IP 接收问题
- android - 获取 EditText 的第一行文本
- php - 仅更改主页 URL(固定链接)Wordpress
- windows - FMX:如何在 Windows 中强制使用特定 GPU 实现高性能?
- c# - WinForms (.NET Framework) 似乎没有注意到 RDP 会话之间的 DPI 会话
- android - 在自动调整大小并再次设置文本后重置 TextView textSize
- java - 肥皂服务 | 彩信 MM7 | 交货报告 Rsp | 状态码 4000 | 无法检索信息 | 升级jdk 8u251
- python - Scrapy 错误显示当没有数据可抓取对象时
- qt - QML 中未定义复数形式的 tr()
- sql - 用于更新数据并将更新值记录在 CLOB 中的 SqlPlus 脚本