Create New Page
How to Create a New Page
Here is the example on how to create your custom page and add it to the leftsidebar menu, breadcrumbs and also meta tag.
1. Create a new folder in src/views. ex. newPage,
and
then create a vue file in src/views/newPage with name
index.vue
Example :-
-
Create one folder in components , name of new page and it will have
utils.tsandindex.vuefile.- In
utils.tsfile it will have breadcrumbs.import { BreadcrumbType } from "@/app/common/types/breadcrumb.type"; export const breadcrumb: BreadcrumbType[] = [ { title: "main-folder-title", disabled: false, }, { title: "page-name", disabled: true, }, ];- In
index.vuefile it will have all you code. Initially it can have code as per below,<script lang='ts' setup> </script> <template> </template>
lang='ts' for
typescript support and setup for optionAPI.
src/views/newPage/index.vue
file it will import above component and utils.<script lang="ts" setup>
import { breadcrumb } from "@/components/newPage/utils";
import NewPage from "@/components/newPage/index.vue";
</script>
<template>
<Breadcrumb title="NewPage Title" :items="breadcrumb" />
// It will use global component of breadcrumb and set data using breadcrumb passed in items.
<NewPage /> // Entry page component for new added route
</template>
2. How to add new route ?
You can easily add, change or remove any route by simply making changes described below:
1. Open src/components/layouts/utils.ts file,
add your route in menuItems. E.g.
{
label: "name", // it will translate by default, so add key directly here
icon: "icon-name",
link: "/link-name",
},
{
label: "parent-label",
icon: "icon",
id: "parent-id",
prefix: "prefix-value", // if you have submenu items to it
subMenu: [
{
label: "child-label",
link: "/link-to-child-route"
},
]
},
subMenu in
that 2nd level route.
{
path: `route-path`,
name: "NewPageComponent", // It should be unique
component: () => import("@/views/newPage/index.vue"),
meta: {
title: "Title",
authRequired: true,
layout: DefaultLayout // or use AuthLayout for auth pages
},
},
3. Add a navigation in the layouts
It will add route to all layouts i.e vertical, horizontal, two column. For more details, check the Layouts page to see how to add menu item in your template.
-
For adding menu item :-
src/components/layouts/utils.ts -
For adding route :-
src/router/routes.ts