簡體   English   中英

使用 Visual Studio Code 在 HTML 文件中啟用 ES6

[英]Enable ES6 in HTML file with Visual Studio Code

VS Code 0.8.0 警告我必須編寫 jsconfig.json 文件來設置 ES6 選項,但它似乎只適用於 JS 文件,而不適用於 HTML 文件。 它不會抑制 HTML 中的錯誤。

如何在 HTML 文件中抑制此錯誤?

jsconfig.json 文件:

{
    "compilerOptions": {
        "target": "ES6",
        "module": "commonjs"
    }
}

html文件:

<html>
<head>
  <meta charset="utf-8">
  <title>Mocha Tests</title>
  <script>
    document.addEventListener("DOMContentLoaded", () => { // Error: This can only be used with ES6. Make sure to have a jsconfig.json-file which sets the target to ES6.
    })
  </script>
</head>
<body>
  <div id="mocha"></div>
</body>
</html>

我不知道您是否可以立即抑制錯誤,但這是一個已確認的錯誤。 請密切關注有關此問題的錯誤報告,並在修復后進行更新: https : //github.com/Microsoft/vscode/issues/559

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM