我已经在app.module.ts中添加了MatButtonToggleModule。即使在那之后,它显示垫子按钮切换不是一个已知的元素。我重新启动了我的代码编辑器,我运行了npm install。即使做了这些,它仍然显示相同的。我也检查了其他的解决方案,但一切都说,只是导入MatButtonToggleModule从angular材料。
我已经附上了错误图像
App.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {FormsModule, ReactiveFormsModule} from '@angular/forms'
import { AppComponent } from './app.component';
import { IonicModule } from '@ionic/angular';
import { environment } from '../environments/environment';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { AppRoutingModule } from './app-routing.module';
import {MatTooltipModule} from '@angular/material/tooltip';
import { DashComponent } from './components/dash/dash.component';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatCardModule } from '@angular/material/card';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { LayoutModule } from '@angular/cdk/layout';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatTableModule } from '@angular/material/table';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatSortModule } from '@angular/material/sort';
import { MiniCardComponent } from './components/dash/mini-card/mini-card.component';
import { NavComponent } from './components/nav/nav.component';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatListModule } from '@angular/material/list';
import {MatSelectModule} from '@angular/material/select';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { ConfigurationComponent } from './components/configuration/configuration.component';
import {MatDividerModule} from '@angular/material/divider';
import {MatExpansionModule} from '@angular/material/expansion';
import { MatInputModule } from '@angular/material/input';
import {MatTreeModule} from '@angular/material/tree';
import { SidebarComponent } from './components/sidebar/sidebar.component';
import { FooterComponent } from './components/footer/footer.component';
import {MatDialogModule} from '@angular/material/dialog';
import { AccountComponent } from './components/account/account.component';
import { ConfirmPromptComponent } from './components/confirm-prompt/confirm-prompt.component';
import { CookieModule } from 'ngx-cookie';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import { ServiceWorkerModule } from '@angular/service-worker';
import { UpdatePromptComponent } from './components/update-prompt/update-prompt.component';
import { NgChartsModule } from 'ng2-charts';
import { DatePipe } from '@angular/common'
import { JwtInterceptor } from './modules/authentication/helpers/jwt.interceptor';
import { ErrorInterceptor } from './modules/authentication/helpers/error.interceptor';
import { LoginComponent } from './modules/authentication/components/login/login.component';
import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatRadioModule} from '@angular/material/radio';
@NgModule({
declarations: [
AppComponent,
DashComponent,
MiniCardComponent,
NavComponent,
ConfigurationComponent,
LoginComponent,
SidebarComponent,
FooterComponent,
AccountComponent,
ConfirmPromptComponent,
UpdatePromptComponent
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
NgbModule,
AppRoutingModule,
MatTooltipModule,
MatGridListModule,
MatCardModule,
MatMenuModule,
MatIconModule,
MatButtonModule,
LayoutModule,
BrowserAnimationsModule,
MatTableModule,
MatPaginatorModule,
MatSortModule,
MatToolbarModule,
MatSidenavModule,
MatListModule,
MatSelectModule,
HttpClientModule,
MatDividerModule,
MatExpansionModule,
MatInputModule,
MatTreeModule,
MatDialogModule,
MatButtonToggleModule,
MatRadioModule,
NgChartsModule,
CookieModule.forRoot(),
MatProgressSpinnerModule,
ServiceWorkerModule.register('./ngsw-worker.js', {
enabled: environment.production,
// Register the ServiceWorker as soon as the app is stable
// or after 30 seconds (whichever comes first).
registrationStrategy: 'registerWhenStable:30000'
})
],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
DatePipe
],
bootstrap: [AppComponent]
})
export class AppModule { }
[enter image description here][1]
[1]: https://i.stack.imgur.com/GI7Qi.png
我检查了您的文件,看到您已经创建了一个名为item-wise-report的组件。这个组件没有自己的模块,是吗?它应该在app.module.ts中声明。否则,item-wise-report将无法使用在app.module.ts中导入的MatButtonToggleModule。
我希望它能帮助你,问候。