首页 > 解决方案 > NUXTJS 中的动态路由有两个级别

问题描述

我想在我的应用 NuxtJS 中配置一个路由。这是一个简单的问题。这是我的页面结构:

pages/
--| customers/
-----| _id.vue
--| studies/
-----| _id.vue
-----| Configuration.vue

我有一个带有此路径的页面:myapp.com/studies/3

我想设置这样的路径:myapp.com/studies/3/configuration。

现在这个结构是:myapp.com/studies/configuration

我怎样才能做到这一点 ?

谢谢

标签: javascriptnuxtjs

解决方案


您可以通过将 _id.vue 文件更改为文件夹并创建索引和配置 vue 文件来实现。像这样 ...

 pages/
--| customers/
-----| _id.vue
--| studies/
-----| _id/
--------| index.vue
--------| configuration.vue

现在如果你访问

  1. yourapp.com/studies/3你会得到 index.vue 页面
  2. yourapp.com/studies/3/configuration您将获得 configuration.vue 页面

问我是否不清楚。


推荐阅读