我得到這樣的錯誤預期'風格'是一個字符串數組。 Angular2
Uncaught Error: Expected 'styles' to be an array of strings.
這裏是我的代碼
styleUrls:[
"../../styles/login.component.styles.scss"
],
當我讓他們以同樣的方式聲明,但與樣式文件在同一目錄中存在的部分問題不會發生。
我得到這樣的錯誤預期'風格'是一個字符串數組。 Angular2
Uncaught Error: Expected 'styles' to be an array of strings.
這裏是我的代碼
styleUrls:[
"../../styles/login.component.styles.scss"
],
當我讓他們以同樣的方式聲明,但與樣式文件在同一目錄中存在的部分問題不會發生。
我一直在努力應對類似的事情,同時將現有的角度移植到angular-cli 1.2.6;我們始終使用SCSS。
注意:我不知道我需要做出的修改(下面概述)是來自我們遺留體系結構的構件,是框架的限制還是其他內容,但它們都適用於我。
多的調試和從各種渠道試圖建議後,我發現了一些的WebPack魔法使從一個@Component
文件引用導致的編譯CSS的styleUrl[]
這也是.angular-cli.json
的styles[]
陣列被解釋爲{}
。預期的輸出是編譯後的SCSS文件的CSS表示形式。
那麼這將導致angular-compiler
的assertArrayOfStrings()
調用throw
與莫屬Expected '" + identifier + "' to be an array of strings.
我不得不作出以下修改我的申請得到它的工作:
app.component
的styleUrls[]
陣列必須移動到.angular-cli.json
的app[0].styles[]
陣列。app.component
的styleUrls[]
數組應該是空的。app.component
的encapsulation: ViewEncapsulation.None
meta-decorator可以被刪除。.angular-cli.json
的app[0].styles[]
數組中引用的樣式表不能在任何組件的styleUrls[]
裝飾器中引用。I filed an issue爲此。
'styleUrls:[ require(「../../ styles/login.component.styles.scss」) ]'? – echonax
我得到**無法找到模塊「。」** – Stefan
我真的不明白爲什麼這不起作用,我甚至在一個有角度的項目中測試它,它工作。我懷疑還有其他的錯誤。你有其他的錯誤信息嗎?當你使用'ng serve'或者當你爲生產構建時會出現這個錯誤嗎?這是一個角度cli生成的項目?你彈出生成webpack.config文件? –