javascript - 我们可以将 SPA 概念与 Nuxt.js 中的动态嵌套路由结合起来吗?

标签 javascript nuxt.js

在我的 Nuxt.js 应用程序中,我必须使用动态嵌套路由。这意味着我最终将生成各种 HTML 文件。问题是我必须将整个应用程序嵌入现有网站中,准确地说是特定页面上。一开始我以为只需要一页,但最后我最终得到了多页。

  1. 考虑到这些限制,我如何嵌入我的文件?有什么办法吗?
  2. 是否可以组合 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/

相关文章:

javascript - 我将如何在 node.js 中唯一标识一台计算机?

javascript - 如何查找 href 值包含两个给定字符串的 <a> 元素

Javascript 如何在运行下一行代码之前等待 x 秒?

node.js - Docker 中的 Nuxt.js : missing dependencies

vue.js - 如何将完成的 nuxt.js 应用程序部署到网络服务器?

javascript - ajax 请求只是 html 文件的一个片段

JavaScript 调试在 Visual Studio 2010 中不起作用

javascript - 在 Nuxt 中设置 SameSite cookie 属性

vue.js - 使用 Nuxt.js 时动态 Vuex 模块初始化的最佳方法是什么?

javascript - 如何使用 `@click` 将 href 传递到 Vue js 中的方法?