2017-01-13 10 views
0

私はTypeScriptプロジェクトを作成しています。この行の実行時に、私は次のエラーが表示されますTypeScript上で、JavaScriptランタイムエラーを受け取る新しいCSSStyleSheet():オブジェクトはこのアクションをサポートしていません

var stylesheet:CSSStyleSheet = new CSSStyleSheet(); 

JavaScript runtime error: Object doesn't support this action

誰もが私が間違っているの何をお勧めすることはできますか? MDNから

+0

TypeScriptコードがJavaScriptに正しくコンパイルされていないようです。 JavaScriptの新しいCSSStyleSheet()のようにサポートされるものはありません。 – IftiKhan

答えて

0

A CSSStyleSheet object is created and inserted into the document's styleSheets list automatically by the browser, when a style sheet is loaded for a document. As the document.styleSheets list cannot be modified directly, there's no useful way to create a new CSSStyleSheet object manually. ... To create a new stylesheet, insert a <style> or <link> element into the document.

基本的に、通常のコンストラクタ関数を使用してCSSStyleSheetオブジェクトを作成することはできません。 HTMLを使用してブラウザに委譲するだけで、その結果を得ることができます。

関連する問題