2017-07-04 42 views
2

我想添加材料設計到jhipster生成的網關。雖然它似乎在工作,但我在控制檯上看到了這個警告;如何將角材設計添加到jhipster

Could not find Angular Material core theme. Most Material components may not work as expected. For more info refer to the theming guide: https://material.angular.io/guide/theming 
Could not find HammerJS. Certain Angular Material components may not work correctly. 

以下行添加到的package.json依賴

"@angular/material": "^2.0.0-beta.7", 
"hammerjs": "^2.0.8", 

以下行添加到global.scss

@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,400i,500,700'); 
@import '[email protected]/material/prebuilt-themes/indigo-pink.css'; 

只是注意,如果我註釋掉靛藍pink.css線UI變得醜陋,所以我得出結論,這個CSS是未經評論導入成功。

Jhipster版本是4.5.6

有什麼可以爲警告

編輯的原因1:這解決了hammerjs警告https://stackoverflow.com/a/41322757/795168,但仍主題預警和問題上的UI繼續

+0

刪除bootsrap包並試試這個 –

回答

0

安裝@角度/材料庫並將相關性添加到package.json

npm install --save @angular/material 

導入角度材料NgModule進入你的應用程序模塊...

import { MaterialModule } from '@angular/material'; 

@NgModule({ 
    imports: [ 
    ... 
    MaterialModule 
], 
    ... 
}) 

既然項目已設置,它必須配置爲包含主題的CSS。角度材料附帶一些預構建主題,位於node_modules/@ angular/material/prebuilt-themes /中。

要角CSS主題和材料圖標添加到您的應用程序

@import '[email protected]/material/prebuilt-themes/deeppurple-amber.css'; 
@import '~https://fonts.googleapis.com/icon?family=Material+Icons'; 

請與鏈接Install Angular Material

+2

我已經完成了所有這些步驟,你知道jhipster嗎?問題與jhipster有關 – ygk

+0

我創建至少一個應用程序的jhipster應用程序。 jhipster完全支持角度cli。這工作。你確切的問題是什麼? –

+0

它不工作..我得到相同的錯誤 – ygk

0

添加角材料通過刪除hammerjs到monolothic jhipster項目爲我工作檢查是否安裝了它

npm uninstall hammerjs --save 

,並驗證在的package.json文件中刪除