发生此错误是因为您只是直接从浏览器中打开html文档。要解决此问题,您需要从网络服务器提供代码并在localhost上访问它。如果您有Apache设置,请使用它来提供文件。一些IDE已内置Web服务器,例如JetBrains
IDE,Eclipse …
如果您具有Node.Js设置,则可以使用http-server。只需运行
npminstallhttp-server-g,您就可以在像这样的终端中使用它
http-serverC:locationtoapp。

发生此错误是因为您只是直接从浏览器中打开html文档。要解决此问题,您需要从网络服务器提供代码并在localhost上访问它。如果您有Apache设置,请使用它来提供文件。一些IDE已内置Web服务器,例如JetBrains
IDE,Eclipse …
如果您具有Node.Js设置,则可以使用http-server。只需运行
npminstallhttp-server-g,您就可以在像这样的终端中使用它
http-serverC:locationtoapp。