javascript - NUXTJS 中的动态路由有两个级别
问题描述
我想在我的应用 NuxtJS 中配置一个路由。这是一个简单的问题。这是我的页面结构:
pages/
--| customers/
-----| _id.vue
--| studies/
-----| _id.vue
-----| Configuration.vue
我有一个带有此路径的页面:myapp.com/studies/3
我想设置这样的路径:myapp.com/studies/3/configuration。
现在这个结构是:myapp.com/studies/configuration
我怎样才能做到这一点 ?
谢谢
解决方案
您可以通过将 _id.vue 文件更改为文件夹并创建索引和配置 vue 文件来实现。像这样 ...
pages/
--| customers/
-----| _id.vue
--| studies/
-----| _id/
--------| index.vue
--------| configuration.vue
现在如果你访问
yourapp.com/studies/3
你会得到 index.vue 页面yourapp.com/studies/3/configuration
您将获得 configuration.vue 页面
问我是否不清楚。
推荐阅读
- javascript - 从 DOM 中移除元素
- macos - macOS中名为“提示”的zshell命令?
- c# - 在 NSwag 中是否可以只生成 C# 客户端接口并使用一些自定义属性注释它们的方法?
- java - 明确提到主要功能但出现错误:在类服务器中找不到主要方法
- mysql - 嵌套集合 SQL 查询以检索每个节点的第一个祖先
- github - 如何在 Web 中恢复我的 GitHub 存储库设置?
- typescript - 使用通用键和预定义的键声明 typescript 类型
- html - 固定定位问题
- java - 无法正确调用 Java 中的 void 函数以输出到控制台
- vue.js - VueJS - prod build 从 HTML 中删除属性引号