0
スタイルの配列を構築するとき、私は、最新の角度使用しています - バージョン4. 私のコンポーネントは、このコードを持っていますAngular4:エラー動的
export function getCssUrl(){
return 'http://localhost/foo/foo.css';
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styles: ['@import "' +getCssUrl()+'"'],
encapsulation: ViewEncapsulation.None
})
export class AppComponent implements OnInit {}
私が仕えるNG実行すると、スタイルがgetCssUrl機能、つまり、正常に動作しますが解決され、CSSが正しく読み込まれます。 ng buildもうまく動作します。私は NGビルド-prod を実行したときしかし、その後、私はエラーを取得:
ERROR in Error encountered resolving symbol values statically. Calling function 'getCssUrl', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppComponent
'styleUrls'を試しましたか? – Jigarb1992
同様にstyleUrlsにも同じ問題があります。 – vanval
'styleUrls:[getCssUrl()]'を使ったことがありますか?私は 'styleUrls'の@importの必要はないと思う。 – Jigarb1992