更新时间:2023-12-05 08:25:40
我已经搜索了几个小时,发现可以通过服务器(例如node.js)托管我的应用
I've googled that for hours and found out that I can host my app by a server (like node.js)
是
,然后允许CORS.
and then to allow CORS.
由于它将是同源的,因此您不需要CORS.
Since it will be Same Origin, you won't need CORS.
但是我不需要任何服务器.我只需要一个简单的html和一个js文件.
However I don't want any server. I want just a simple html and a js file.
然后,您将无法使用浏览器端的ES6模块.
Then you can't use browser-side ES6 modules.
您首先需要编写代码以不使用模块,或者使用Webpack或Rollup之类的代码将代码转换为不使用模块.
You'll need to either write the code to not use modules in the first place, or use something like Webpack or Rollup to convert the code to not use modules afterwards.