无法在第三方工具 iframe 中预览使用 Vite 开发的 Vue 应用(但可以使用 Vue CLI)
我正在开发一个 Vue 应用程序,它将被“iframed”到第 3 方框架中。我可以在 localhost 下本地开发我的应用程序,但为了在第 3 方工具中预览它,URL 应为:https://localhost:5001/sampleapp/index.html
。
我有同一个应用程序的两个版本。第一个是使用 Vue-CLI 构建的,第二个是使用 Vite 构建的。
当我尝试预览应用程序的 Vite 版本时,我看到一个空白页面。
当使用 Vue CLI 版本时,我得到了一个可以工作的应用程序,并且可以像平常一样开发它,并且它在 iframe 中“热重载”。
如何使用 Vite 实现同样的效果?
I am developing a Vue app that will be "iframed" into a 3rd party framework. I can develop my app locally under the localhost, but in order to preview it in the 3rd party tool, the URL should be: https://localhost:5001/sampleapp/index.html
.
I have two versions of the same app. One was built with Vue-CLI and the 2nd one with Vite.
When I try to preview the Vite version of the app, I get a blank page.
When using Vue CLI version, I get a working app and can develop it as I would normally do, and it 'hot-reloads' in the iframe.
How do I achieve the same with Vite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@edytajordan 的回答:
事实证明,对于 Vite 版本,我实际上必须在预览模式下运行应用程序。我的最终 vite.config.js:
然后运行 npm run build && npm 运行预览。
@edytajordan's answer:
It turned out, that for the Vite version, I actually had to run the App in the preview mode. My final vite.config.js:
and then run
npm run build && npm run preview
.