原因就在于vite使用了ESModule,而webpack则是传统的需要将引用捏合打包。如何实现的呢?其实很简单 <script src="./main.js" type="module"></script>