如何在Angular Single SPA应用程序中正确安装Material?

问题描述

我下载了Angular Single SPA的starting project,并且希望在所有不同的应用程序(app1,app2,navbar)中安装和使用Angular Material。我认为,由于这些应用程序是独立的,因此按照here的说明,通常可以在每个程序包中正常安装该软件包。但是,通过这种方式加载了组件,我可以使用它们,但是资产似乎没有。例如,如果我尝试使用

<mat-icon aria-hidden="false" aria-label="Example home icon">home</mat-icon>

我只看到这个:

enter image description here

在这里想念什么?我应该在extra-webpack.config.js文件添加一些内容吗?

编辑。

以下是导航栏项目的app.module.ts

import { browserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { EmptyRouteComponent } from './empty-route/empty-route.component';
import { PrimaryNavComponent } from './primary-nav/primary-nav.component';

import {MatBadgeModule} from '@angular/material/badge';
import {MatButtonModule} from '@angular/material/button';
import {MatIconModule} from '@angular/material/icon';

@NgModule({
  declarations: [
    AppComponent,EmptyRouteComponent,PrimaryNavComponent,],imports: [
    browserModule,AppRoutingModule,MatBadgeModule,MatButtonModule,MatIconModule
  ],providers: [],bootstrap: [AppComponent]
})
export class AppModule { }

这是我的navbar项目的package.json:

{
  "name": "navbar","version": "0.0.0","scripts": {
    "ng": "ng","start": "npm run serve:single-spa","build": "npm run build:single-spa","test": "ng test","lint": "ng lint","e2e": "ng e2e","build:single-spa": "ng build --prod --deploy-url /dist/navbar --output-hashing none","serve:single-spa": "ng serve --disable-host-check --port 4300 --host 0.0.0.0 --deploy-url http://localhost:4300/ --live-reload false"
  },"private": true,"dependencies": {
    "@angular-builders/custom-webpack": "^8","@angular/animations": "~9.1.7","@angular/cdk": "^9.2.4","@angular/common": "~9.1.7","@angular/compiler": "~9.1.7","@angular/core": "~9.1.7","@angular/forms": "~9.1.7","@angular/material": "^9.2.4","@angular/platform-browser": "~9.1.7","@angular/platform-browser-dynamic": "~9.1.7","@angular/router": "~9.1.7","rxjs": "~6.5.5","single-spa": "^5.5.0","single-spa-angular": "^4.0.0","tslib": "^1.10.0","zone.js": "0.10.3"
  },"devDependencies": {
    "@angular-devkit/build-angular": "~0.901.6","@angular/cli": "~9.1.6","@angular/compiler-cli": "~9.1.7","@angular/language-service": "~9.1.7","@types/node": "^12.11.1","@types/jasmine": "~3.3.8","@types/jasminewd2": "~2.0.3","codelyzer": "^5.1.2","jasmine-core": "~3.4.0","jasmine-spec-reporter": "~4.2.1","karma": "~4.1.0","karma-chrome-launcher": "~2.2.0","karma-coverage-istanbul-reporter": "~2.0.1","karma-jasmine": "~2.0.1","karma-jasmine-html-reporter": "^1.4.0","protractor": "~5.4.0","ts-node": "~7.0.0","tslint": "~5.15.0","typescript": "~3.8.3"
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)