路由命名技巧

// src/router/routes.ts
import type { RouteRecordRaw } from 'vue-router'
const routes: RouteRecordRaw[] = [
// 文章相关的路由统一放在这里管理
{
path: '/article',
name: 'article',
// 这是一个配置了 `<router-view />` 标签的路由中转站组件
// 目的是使其可以渲染子路由
component: () => import('@cp/TransferStation.vue'),
// 由于父级路由没有内容,所以重定向至列表的第 1 页
// e.g. `https://example.com/article`
redirect: {
name: 'article-list',
params: {
page: 1,
},
},
children: [
// 文章列表页
// e.g. `https://example.com/article/list/1`
{
path: 'list/:page',
name: 'article-list',
component: () => import('@views/article/list.vue'),
},
// 文章详情页
// e.g. `https://example.com/article/detail/1`
{
path: 'detail/:id',
name: 'article-detail',
component: () => import('@views/article/detail.vue'),
},
],
},
]
export default routes
posted @   Felix_Openmind  阅读(77)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
*{cursor: url(https://files-cdn.cnblogs.com/files/morango/fish-cursor.ico),auto;}
点击右上角即可分享
微信分享提示