Able Pro
Vue Laravel
Vue Laravel
  • Documentation
  • Installation
  • Directory Structure
  • ⛱️Theme UI
    • 🎛️Icons
    • 👓Change Logo
    • 🆎Change Typography
    • 🔮Theme Colors
    • ⚙️Theme Settings
    • ⬅️RTL
  • 👩‍💻Development
    • Database Connection
    • Sanctum Integration
    • Sanctum Authentication
    • Frontend API
    • State Management
    • Axios API Calls
    • Routing
  • Perfect Scrollbar
  • Layouts
  • Create a new page
  • Remove Auth
  • Dependencies
  • Roadmap
  • Changelog
Powered by GitBook
On this page
  • Create demo page
  • Subpath URL
  • Dynamic URL✌️
  • Plugins

Create a new page

only create new file in resources/ts/pages directory and you will have new page with auto generated route.

Create demo page

Create a new file which is demo.vue in resources/ts/pages directory with the following content

<template>
  <p>This is about page</p>
</template>

It will auto register the route with /demo url in typed-router.d.ts. Navigate to that route and you will find the rendered content of demo.vue file.

// typed-router.d.ts file
'demo': RouteRecordInfo<'demo', '/demo', Record<never, never>, Record<never, never>>,

Subpath URL

To create a URL which has something like /dashboards/default, we need to create dashboards folder and have to place default.vue file inside dashboards folder.

Let's create a new folder named dashboards in resources/ts/pages directory. Inside this folder let's create a new file default.vue with the following content.

<template>
  <p>This is Default page.</p>
</template>

then it will generate route with the URL like this:

// typed-router.d.ts file
'dashboards-default': RouteRecordInfo<'dashboards-default', '/dashboards/default', Record<never, never>, Record<never, never>>,

Dynamic URL✌️

Let's we want to create a dynamic route like /customers/<id>, where id can be any number.

For this create new folder named customers in resources/ts/pages directory and inside customers create a new file with the name [id].vue. Place below content inside this create file:

<script setup lang="ts">
const route = useRoute('customers-id')
</script>
<template>
   <h1>Extra page id : {{ route.params.id }}</h1>
</template>

Above code create new Route url which is like this:

// typed-router.d.ts file
'customers-id': RouteRecordInfo<'customers-id', '/customers/:id', { id: ParamValue<true> }, { id: ParamValue<false> }>,

With this, if you visit /customers/1 it will render Extra page id : 1. here, 1 is taken from URL.

If you visit /customers/2 then it will render Extra page id : 2. It is really very easy to create url using parameter.

Plugins

The following plugins auto-generate routes and wrap layouts in Vue.

Click the links above to view the plugins' official documentation.

PreviousLayoutsNextRemove Auth

Last updated 1 year ago

we want to create a page which can accept ids as parameter and we want to fetch data according to that id. This is called in terms of vue-router.

dynamic route
unplugin-vue-router
vite-plugin-vue-layouts