0
有沒有一種方法可以引用在我的類型腳本類中的html文件中定義的JavaScript變量<script>
標記?打字稿三重斜槓指令引用html文件
我正在開發一個帶有typescript的angular2應用程序,它需要一些普通的JavaScript變量,這些變量在index.html中的<script>
中進行了聲明和分配。當我試圖在我的打字稿類中引用它們時,出現如下錯誤。
沒有參考下面得到錯誤:
app/services/Resources.ts(8,41): error TS2339: Property 'Resources' does not exist on type 'Window'.
當我嘗試引用的index.html它顯示如下錯誤
/// <reference path="../../index.html" />
app/services/Resources.ts(1,1): error TS6054: File 'C:/quickstart/index.html' has unsupported extension. The only supported extensions are '
.ts', '.tsx', '.d.ts'.
讓我試試。感謝你的回答。 –
它的工作,感謝節省我的一天 –