在我的 Nuxt.js 应用程序中,我必须使用动态嵌套路由。这意味着我最终将生成各种 HTML 文件。问题是我必须将整个应用程序嵌入现有网站中,准确地说是特定页面上。一开始我以为只需要一页,但最后我最终得到了多页。
- 考虑到这些限制,我如何嵌入我的文件?有什么办法吗?
- 是否可以组合 SPA动态嵌套路由的概念?
最佳答案
这些概念并不相互排斥,您只需将 nuxt.conf.js 模式设置为“spa”,其他一切都可以保留。
据官方documentation :
So, for an SPA deployment, you must do the following:
- Change mode in nuxt.config.js to spa.
- Run npm run build.
- Deploy the created dist/ folder to your static hosting like Surge, GitHub Pages or nginx.
无需任何进一步配置,您就可以部署您的应用程序。
另请注意:
nuxt generate still needs SSR engine during build/generate time while having the advantage of having all our pages pre rendered, and have a high SEO and page load score. The content is generated at build time. For example, we can't use it for applications where content depends on user authentication or a real time API (at least for the first load).
这意味着您需要在安装了 ssr 工具的环境中生成页面。
还有下一段
关于javascript - 我们可以将 SPA 概念与 Nuxt.js 中的动态嵌套路由结合起来吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52820584/